sqspat has asked for the wisdom of the Perl Monks concerning the following question:
my $ssh = Net::SSH::Expect->new ( host => "obe140", user => 'root', password => 'admin', raw_pty => 1, timeout => 1 ); #eval { my $login_output = $ssh->login(); if ($login_output !~ /blah/) { die "Login has failed. Login output was $login_output"; } #}; my ($command_file, $commands)= undef; #Open the file with the commands to be issued open(FILE, "input/CMsettings") or die("Unable to open file"); my @commands = <FILE>; close (FILE); $ssh->exec("stty raw -echo"); my $command_run =undef; my @commands_run =(); sleep(1); #insert sleep here so command can be returned. my @issued_commands; #Issue the commands from the comand file foreach my $command1 (@commands){ chomp $command1; $command_run = $ssh->exec($command1); sleep(1); print $command_run; sleep(1); push (@commands_run, $command_run); print "\n\n-----------\n"; } print "\n\n ---- reboot ----\n"; # Issue reboot command my $reboot_command = $ssh->exec('reboot'); -- script drops out here w +hen would like it to hang around until the box is back up and running + so it can issue more commands ????? $ssh->close(); sleep(2); # ---- Login post reboot ----- my $ssh2 = Net::SSH::Expect->new ( host => "obe140", user => 'root', password => 'admin', raw_pty => 1, timeout => 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ssh connection lost during script running when box rebooted and script falls out...
by quester (Vicar) on Jul 21, 2009 at 12:34 UTC | |
|
Re: ssh connection lost during script running when box rebooted and script falls out...
by afoken (Chancellor) on Jul 22, 2009 at 09:56 UTC |