If I were you, I would run all the 1000 commands as background jobs, just to avoid any network issues. You list the commands you want to run into a shell script, upload the shell script via ssh, then execute the 1000 command script as nohup background jobs. Then come back in at a later time, and collect the results.
Using Net::SSH2 it is necessary to use the following shell syntax to execute background commands. Notice the closing of the standard filehandles, and the redirects to log files as output.
If you did it correctly, it should avoid any hassle with the ssh connection.
my $chan = $ssh2->channel(); $chan->blocking(1); $chan->exec("nohup /home/user/myscript > myscript.out 2> myscript.err +< /dev/null &"); $chan->send_eof; exit;
In reply to Re: sending hundreds of commandos on SSH connection
by zentara
in thread sending hundreds of commandos on SSH connection
by JGmonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |