in reply to NET::SSH2 Terminates
If those settings don't do it, you might try the various methods available in perldoc Net::SSH2::Channel. For instance:
Setting blocking to 1, or instead of $chan2->close; you might try $chan2->send_eof, or ask for a pty with $chan2->pty
There is a problem with a Net::SSH2 connection compared to a c ssh utility connection, in that the c utility will automatically detach itself when you try to run a background process.... it shows up in my pid list designated as as no_tty ? But with Net::SSH2, you need to manually do it. Thats my incomplete understanding.
There is some updated example code for exec'ing a program into the background at A little demo for Net::SSH2, and you may have to do that as a last resort.
But for your particular problem, it sounds like you are closing $chan2, before the data can be completely transferred, and the randomness of the amount of return you get, is just system load variations playing out, while the $chan2->close is executed. Have you tried commenting out $chan2->close; and do a wait_closed or something similar, as described in perldoc Net::SSH2::Channel?# to run a remote command in the background # you need to semi-daemonize it by redirecting it's filehandles my $chan3 = $ssh2->channel(); $chan3->blocking(1); $chan3->exec("nohup /home/zentara/perlplay/net/zzsleep > foo.out 2> fo +o.err < /dev/null &"); $chan3->send_eof;
|
|---|