Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Incorrect value 0 reported in command execution return value variable $?, when trying with expect->send command

by Perlbotics (Abbot)
on Feb 25, 2012 at 14:20 UTC ( #956117=note: print w/ replies, xml ) Need Help??


in reply to Incorrect value 0 reported in command execution return value variable $?, when trying with expect->send command

Insert this line and the solution will reveal before your weary eyes...

print "$command ; echo COMMAND_RET:$? | sed 's/^/COMMAND_OUT: /g'; ech +o -n END_; echo EXPECT\n";
Hint: You need to escape $?.

Why not get rid of the sed-invocation?

$exp->send("$command ; echo 'COMMAND_OUT: COMMAND_RET:'\$?; echo END_E +XPECT\n");
Depending on the shells flavour of echo, you could also get rid of the second echo invocation.


Comment on Re: Incorrect value 0 reported in command execution return value variable $?, when trying with expect->send command
Select or Download Code
Re^2: Incorrect value 0 reported in command execution return value variable $?, when trying with expect->send command
by Davewhite (Acolyte) on Feb 27, 2012 at 07:14 UTC

    Thanks a lot for the guidance. It's working as per your suggestion.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://956117]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-12-19 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (75 votes), past polls