Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running scripts

Status
Not open for further replies.

huskers

Programmer
Jan 29, 2002
75
US
Hi,

I have 3 scripts that I need to run one after the other i.e. the second script gets kicked after the first one is done and so on. I do not know how long each script takes to run. Could anyone tell me how i cam acheive this. I am new to tcl so any help would be appreciated.

Thanks
 
For *N*X and Windows, you can use 'exec':
exec -- $script1
exec -- $script2
exec -- $script3

The three shell scripts will be exec'ed one after the other.

You should read the Tcl manual exec page for more information.

HTH

ulis
 
Thanks for the reply. If i have three scripts a, b, c that need to be executed one after the other and if my program goes something like this:

#!/usr/local/wictcl/bin/wictcl
exec a
exec b
exec c

According to my understanding if i run this process in the background, then this program will fork three shells each executing that particular script but i do not want it that way. line 2 should be executed only after line 1 is done and so on.

Thanks
 
'exec' can work as you described but with a slighter different syntax:

exec $cmd &

With the & appended to the command, Tcl launches a shell and continues the execution of the Tcl script without waiting.

With the syntax I indicated Tcl does another thing:
It waits for the completion of the script before continuing, this to be able to get the result of the exec'ed script.

set here [exec pwd]

will result of the current working directory -returned by pwd- to be put in the here variable.

Don't be fooled:

exec pwd

will wait because the final & is not here.

So, the code:

exec $script1
exec $script2
exec $script3

will do what you want.

To be convinced, make a try and see what happens.

HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top