I came across this link: Exit status code for Expect script called from Bash but it did not help me. As I was looking to get the exit status code from a command run remotely, I came across cpan documentation for Net::SSH::Expect 0.08 which has "collect_exit_code" and "last_exit_code" methods, which is exactly what I'd like to use today, however, I'm unable to find a suitable replacement when running 1.09.
I'd like to keep it simple, such as:
$ssh_devel_exp->collect_exit_code(1);
$ssh_devel_exp->send("sudo make");
if ($ssh_devel_exp->last_exit_code()) { etc. and so forth... };
But, I cannot think of a simple way to get the exit status when running a command through Net Expect without methods similar to these.
I do not believe switching to Fabric is the answer for this issue; this is a perl application and I need to stick with Perl.
Thanks in advance.
Did you tried to call the underlying expect object?
if nothing else helps you could create a small shell script that execute your commands and report back the exitstatus on stderr.