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

iostream.h

macrumors regular
Original poster
Mar 4, 2004
231
0
Albuquerque, NM
I'd like to have a specific shell script complete before a function is called. This command has no specified time limit. All documentation I have found online shows how to pause the script for a certain task to finish within an application, not for a "do shell script" command itself. Secondly, I don't want to freeze up any other processes when this is stalling. Anyone know how to do this?

Code:
do shell script "somecommand"
-- Something Here
my function()
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
AFAIK, "do shell script" waits for the script to finish execution.

It will also only block your process, not any other processes.
 

redeye be

macrumors 65816
Jan 27, 2005
1,138
0
BXL
Could it be that a script returns a value on completion (like 0 if succeeded, something else when an error occurred). Maybe i'm thinking of functions to much.
You could test it out quite easily.

I could be dead wrong though ;)
 

iostream.h

macrumors regular
Original poster
Mar 4, 2004
231
0
Albuquerque, NM
The command is "open -a /Applications/iTunes.app ~/Backup/Music/*".

So I guess a more appropriate question is to find out how to determine whether iTunes is busy or not.
 

iostream.h

macrumors regular
Original poster
Mar 4, 2004
231
0
Albuquerque, NM
The command is "open -a /Applications/iTunes.app ~/Backup/Music/*".

So I guess a more appropriate question is to find out how to determine whether iTunes is busy or not.

On a related note, iTunes does not have "is busy" or anything similar.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
In your case, "do shell script" waits for the script to end, so it's working how it should. "open" simply launches another process if the path given is a process. So you need to think in different terms....
 

nichos

macrumors 6502
Jul 17, 2004
372
0
Jacksonville, Fl
Kind of crude, but what about something like:
command1
sleep(length)
command2

I don't know if "sleep" is valid or not, you'd have to man bash, or maybe sleep. What does this command of yours do? Open your backup/music folder in itunes? If so, and I don't know much about how iTunes works, but could you make a symlink from your backup/music to /path/to/itunes/library? I tunes might use some sort of DB, so I don't know if that will work.
 

Thom_Edwards

macrumors regular
Apr 11, 2003
240
0
have the called script create a file when it completes, then have the calling code go into a while loop that doesn't break until it finds the file. don't forget to delete the file after breaking out of the loop, though! this should work if i'm understanding your problem correctly.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.