Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by Perlbotics (Canon)
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 browsing the Monastery: (11)
As of 2015-07-05 20:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls