Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gugge99

macrumors newbie
Original poster
Feb 8, 2011
14
0
Trondheim, Norway
Which is why LPZ and others have questioned your choice of tools. Xcode and Applescript vs. TexShop or even emacs/Aquamacs.

You are trying to adapt a Phillips screwdriver to turn a flathead screw. Sure, you can probably get it to work with enough effort, but it will never be as ideal as using the right tool in the first place.

B

I do understand that. Therefore I've tried to be as short as possible such that I could solve the little problem that I have. Which originally was, quit Terminal when command line has executed. Or in other words, find a sandpaper to file my Phillips screwdriver such that it looks like a flathead screwdriver and works to its purpose.
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
Ok, thanks for the suggestion but I don't think this is something for me. Already used a lot of hours getting the Applescript to nearly function and would rather use my bug-program than have to use another 10-20 hours to set this up and learn it. In the end, I am only trying to work this out to save time. Sofar I've used to much time working on my Applescript.

10-20 hours already spent. Okay. But... How do you know if it'd take another 10-20 hours, or even more, to find and use your sandpaper? Whereas changing tack now and going with one of the alternative methods might only take 2-4 hours? This seems to be what those who are experienced at this are suggesting.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,420
A sea of green
I do understand that. Therefore I've tried to be as short as possible such that I could solve the little problem that I have. Which originally was, quit Terminal when command line has executed. Or in other words, find a sandpaper to file my Phillips screwdriver such that it looks like a flathead screwdriver and works to its purpose.

If you're just looking for quick fixes, then use a file as a sentinel flag.

Delete the file before the command starts (the 'rm' command can do this, or do it in AppleScript). Create the file after the command ends (the 'touch' command can do this). Change your AppleScript so it loops, looking for the existence of the file.

It won't do the dependency analysis, but if you're willing to use sandpaper on a Phillips screwdriver, it's a small price to pay to keep the time you've invested so far.

And I don't know why you think it's a "little problem" to solve. Just because a problem is easily described does not mean a solution is easy to make. It might be easy for someone with considerable experience, or it might be that someone with experience will tell you it's much more complex than you think.
 

gugge99

macrumors newbie
Original poster
Feb 8, 2011
14
0
Trondheim, Norway
If you're just looking for quick fixes, then use a file as a sentinel flag.

Delete the file before the command starts (the 'rm' command can do this, or do it in AppleScript). Create the file after the command ends (the 'touch' command can do this). Change your AppleScript so it loops, looking for the existence of the file.
think.

Thanks for the answer. I guess I assumed the problem was easier to fix than it was. Thought there was something like "ok user, I'm done with the execution, here is the results". Anyway, how would you do such a thing in Applescript? If I have something like:
Code:
???
do script "something"
do script "something else"
???
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,420
A sea of green
Thanks for the answer. I guess I assumed the problem was easier to fix than it was. Thought there was something like "ok user, I'm done with the execution, here is the results". Anyway, how would you do such a thing in Applescript? If I have something like:
Code:
???
do script "something"
do script "something else"
???

I don't know what you mean by "the results".

If you mean "the output from the commands that would normally appear in the Terminal window", then you can use shell redirection to a file, or you can simply assign the return value of do shell script to an AppleScript variable.

Shell redirection:
Code:
do shell script "cd ~/Documents; ls -la >results.txt"
The results of the 'ls -la' command will now reside in the file "~/Documents/results.txt".

AppleScript variable assignment:
Code:
set scriptOutput to do shell script "cd ~/Documents; ls -la"
The output is now in the AppleScript variable scriptOutput.


You said you're new to AppleScript. Do you know any programming languages?


EDIT:
I just looked at the dummy project:
http://dl.dropbox.com/u/13082737/dummyProject.zip
but I don't see any Automator or AppleScript in it.
 
Last edited:

gugge99

macrumors newbie
Original poster
Feb 8, 2011
14
0
Trondheim, Norway
I don't know what you mean by "the results".

If you mean "the output from the commands that would normally appear in the Terminal window", then you can use shell redirection to a file, or you can simply assign the return value of do shell script to an AppleScript variable.

Shell redirection:
Code:
do shell script "cd ~/Documents; ls -la >results.txt"
The results of the 'ls -la' command will now reside in the file "~/Documents/results.txt".

AppleScript variable assignment:
Code:
set scriptOutput to do shell script "cd ~/Documents; ls -la"
The output is now in the AppleScript variable scriptOutput.


You said you're new to AppleScript. Do you know any programming languages?
With results I only meant like giving a confirmation that the compiling went well or something like that. I don't like that things happen and I can't see it, if you know what I mean?
Ok, so then I'll try something later on. But it will probably work as you mentioned in your preavious posts.
Wouldn't say I know any programming languages but I've worked a little bit with everything, from C to Matlab.
I want to thank all for the replies, I've learned a lot from your answers! Thanks again!
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
With results I only meant like giving a confirmation that the compiling went well or something like that. I don't like that things happen and I can't see it, if you know what I mean?

Maybe you don't like it because it is the wrong tool? I can drive this flathead screw with a butter knife too, but it just doesn't feel right... (Just like earlier in the thread using Automator instead of Script Editor).

Ok, so then I'll try something later on. But it will probably work as you mentioned in your preavious posts.
Several threads revealed by Google imply that the way to get a script to run and wait for it to be done is "do shell script," we've tried that.

Though I can't imagine that
Code:
set scriptOutput to do shell script "cd ~/Documents; ls -la"
wouldn't wait until it was done.

B
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.