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 = ; 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 when 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