I am fairly new to UNIX and very new to this forum too. This is my first post here. Here is my scenario -
I have 3 scripts script1, script2 and script3. I want to start script1 and script2 asynchronously. Upon completion of both scripts script1 and script2, i want to fire the last script script3
I have no information about the platform/application/hardware as this is an interview question. The answer I gave was - I will include these scripts in a file. call 1 and 2 from there and let them run in background. upon successful return I will fire 3. The interviewer was not satisfied with this answer and told me to come up with an answer on next Monday (I have my on-site interview).
Could you please help me with this? Thanks a lot in advance
PS: I did search the forum and found general information about asynchronous lists and stuff. Since i am a newbie in UNIX platform it was kind of too general.
Thank you. Yea, i came across "wait" through my search. And read about it. Please don't misunderstand me. I am not arguing in any way. I am just trying to understand how this will work exactly so I can convince the interviewer. So, in wait(n) 'n' can be a PID. If i don't specify 'n' the master script will wait for all scripts to finish and return and then continue the execution of further code. So, if i go with this approach how will i know what the PID of "script1 &" and "script2 &" is ?
OR if I go with the "wait", without arguments option, does it mean the script3 will read as simple as this :
---------- Post updated at 06:54 PM ---------- Previous update was at 06:50 PM ----------
Thank you. That would be a good approach.
---------- Post updated at 07:02 PM ---------- Previous update was at 06:54 PM ----------
Thanks fpmurphy. You are awesome!
I got to know so many things from your sample code. $$ gives calling process' PID and $! gives the called process' PID.
I am sure I could always replace those functions with script file names.
Hats off to you guys. unix.com rocks!