Your skill will accomplish
what the force of many cannot
Incorrect value 0 reported in command execution return value variable $?, when trying with expect->send commandby Davewhite (Acolyte)
|on Feb 25, 2012 at 13:39 UTC||Need Help??|
Davewhite has asked for the
wisdom of the Perl Monks concerning the following question:
Hi, I am trying to remotely run an executable on a remote machine using the expect.pm module. I am able to successfully connect and execute the executable on remote machine.
Able to successfully get the executable output but facing issue when trying to check the return value of executable run
I am trying in following manner$exp->send("$command ; echo COMMAND_RET:$? | sed 's/^/COMMAND_OUT: /g'; echo -n END_; echo EXPECT\n");
Following format output gets displayed on console
COMMAND_OUT: COMMAND_RET: 0
My problem is that $? value printed in above code always displays 0, while the executable is returning non zero value too for some cases
While trying to manually execute the same command on shell prompt, correct value of $? gets appended COMMAND_OUT: COMMAND_RET: string.
Not able to detect why is S? value with expect->send is showing 0 value always.
Any advice on the same is really grateful