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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help calling 'C' program from perl

Status
Not open for further replies.

KevHart

Technical User
Mar 2, 2004
2
GB
I created a cron in unix that fires off a perl script which in turn calls a 'c' program. The problem is that I need the 'c' program to finish before the script continues on. I first tried exec() but the perl script terminated without continuing when the 'c' program was finished. Then I tried "$command = expect->spawn('c_program');" but it seems the perl script continues without waiting for the 'c' program to finish. Any help would be appreciated.

 
Hello kevhart,

'sounds like you need to use 'system'. It will spawn the child process and wait for it to complete and return the exist status of the child process.
Do, 'perldoc -f system' for more details.
Use it like this.....

@args = ("command","arg1","arg2");
$cmd_exit_status = (system(@args))/256;


HTH


keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top