rogeriovinhal
February 5th, 2007, 09:32 PM
Hello, I am writing a script, but there is something I need that I can't find a way to do it...
I need to make a command in background "command1 &" and then somewhere in the script I need to wait for it to finish before I do command2. Basically, I need this:
start script
...
command1 &
...
more commands to run parallel to command1
...
wait for command1 to finish
command2
end of the script
I've looked a lot of pages, but I couldn't make this simple task to be done. I've seen something about a 'wait' command with the pid process number, but that didn't work also (or I couldn't make it work).
Can anybody help me?
EDIT
Nevermind, I solved it.
To those that may be interested, the problem was that the command1 was a wine call, but it seems that wine calls returns a exit signal even before it stops working, so "wait" didn't wait for it to finish properly. I solved this by executing the 'wine blablabla' command inside a subshell that should return a value at background "$( wine blabla ) &", so now wait really worked.
I need to make a command in background "command1 &" and then somewhere in the script I need to wait for it to finish before I do command2. Basically, I need this:
start script
...
command1 &
...
more commands to run parallel to command1
...
wait for command1 to finish
command2
end of the script
I've looked a lot of pages, but I couldn't make this simple task to be done. I've seen something about a 'wait' command with the pid process number, but that didn't work also (or I couldn't make it work).
Can anybody help me?
EDIT
Nevermind, I solved it.
To those that may be interested, the problem was that the command1 was a wine call, but it seems that wine calls returns a exit signal even before it stops working, so "wait" didn't wait for it to finish properly. I solved this by executing the 'wine blablabla' command inside a subshell that should return a value at background "$( wine blabla ) &", so now wait really worked.