From: Don S. <don...@te...> - 2001-01-24 21:52:29
|
I've been spawning processes via eval and then checking the return code. For example: eval {$MIMS = Expect->spawn($cmd); }; if ($@) { print STDOUT "$ALARM ::: Failed to spawn '$cmd': $! \n"; exit(1); } I've found this to work well in capturing problems with the spawn process itself. Don -----Original Message----- From: Ryan Heatwole [mailto:hea...@re...] Sent: Thursday, January 25, 2001 5:21 AM To: exp...@li... Subject: [Expectperl-discuss] Return Values from spawned process Greetings, I have been trying to find a way to determine the return value (that is: success/fail) of a spawned process (specifically scp). Currently, I am using an Expect match, along with the values the match returns to determine if the spawned command finished or failed. For Example: # Spawn our command $cmd = Expect->spawn($scp); $cmd->expect(60, -re => 'Enter passphrase| password:'); print $cmd "$password\r"; # Check for any returned info from scp command @array = $cmd->expect(undef, -re => '\r\n.+'); $stuff = $cmd->exp_match(); $cmd->soft_close(); if ($array[1] eq '2:EOF') # Finished OK { ... } else # Command Failed { print "We had an error: $stuff\n"; } Is this a proper way to check the status of the spawned process? It seems to work ok, but it also feels a little bit contrived. Thank you in advance Ryan Heatwole _______________________________________________ Expectperl-discuss mailing list Exp...@li... http://lists.sourceforge.net/lists/listinfo/expectperl-discuss |