Dear perl monks,
Within a perl file (on local host), I am trying to run another perl file (on remote host) to completion and get back the control.
line 0: $cmd="/usr/bin/perl Install.pl"; line 1: $ssh = Net::OpenSSH->new($host, user => $user, password => $pa +ssword, port => '22'); $ssh->error and die "Couldn't establish SSH c +onnection: ".$ssh->error; line 2: $ssh->system($cmd) or die "Command failed: ".$ssh->error; line 3: print "Control back to local host\n";
I am able to establish the ssh connection and trigger the $cmd on the remote host to completion successfully. However, the control doesnt come back to the local host. Install.pl, file that runs for a long time (~40 mins) and completes its execution. It prints its last output statement and exits (I have verified that there are no perl processes running on the remote host later that statement) However, the line 3 print command never gets executed and the control hangs indefinitely - I will have to manually kill the process with Ctrl-C to continue.
I increased the debug level for the package and observe the statement "Inappropriate ioctl for device" repeated,
# open_ex: ['ssh','-S','/home/user/.libnet-openssh-perl/user-machine.' +,'-l','user','-p','22','machine','--','/usr/bin/perl Install.pl'], # _waitpid(2829) => pid: 2829, rc: Inappropriate ioctl for device
My guess is that the connection to the remote shell is broken and cannot bring the control back to the original shell.
I have tried other methods of Net::OpenSSH like capture(), capture2() but had no success. I do not want to leave the remote perl file in the background, since I would need to do some post processing after its completion.
Any help on this is highly appreciated
In reply to Net::OpenSSH - Long running remote perl script doesnt bring back the control by sudhakar.betha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |