james_culling has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am getting the below error "SSHProcessError The ssh process was terminated." when I am trying to reboot the ap using the $ssh2->exec("/system/reboot force"); please help.
my $host = "X.X.X.X"; my $usr = "root"; my $pas = "root"; my $ssh1 = Net::SSH::Expect->new ( host => $host, password=> $pas, user => $usr, raw_pty => 1, timeout => 20 ); my $login_output = $ssh1->login(); if ($login_output !~ /#/) { print "Debug: login failed "; $ssh1->close(); } else { $ssh1->cmd("/system/reboot force"); $ssh1->close(); return 0;

Replies are listed 'Best First'.
Re: net-ssh-expect is giving error
by salva (Canon) on Jan 16, 2014 at 12:20 UTC
    Isn't that expected?

    If you reboot the machine, any SSH connection open will be terminated, including the connection launching the reboot!

Re: net-ssh-expect is giving error
by atcroft (Abbot) on Jan 16, 2014 at 15:17 UTC

    Maybe you should push the command into the background (trailing '&' on the command, or whatever the remote system requires), so you can get back a prompt and close as you intend? Just a thought.

    Hope that helps.

      you should push the command into the background

      Maybe, I'm confused here - how will pushing commands to background help when OP does a force reboot?
        Hi All, I think Ericsson device won't support running the command in background. I tried to run the command in background, but its not rebooting.