Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by Perlbotics (Archbishop)
on Feb 25, 2012 at 14:20 UTC ( [id://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

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://956117]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-23 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found