in reply to Re: Net-SSH-Expect & Fedora-18
in thread Net-SSH-Expect & Fedora-18

Thanks for the reply. I believe so. After looking at some of the blogs, it seems like Fedora 18 behaves in the correct manner.

What i am looking is for the Net::SSH to not throw out errors when we perform reboot over ssh

Shutdown would not be an option

Make a small shell script that performs the reboot in the background after a time delay.

Can you elaborate more on this point ? How can this be useful ? I did run the reboot command in the background & didn't observe any benefit

Replies are listed 'Best First'.
Re^3: Net-SSH-Expect & Fedora-18
by RonW (Parson) on Jul 02, 2014 at 17:02 UTC
    Shutdown would not be an option

    The reboot command has no option for a delay, but there is a reboot option for the shutdown command, which also has a delay option.

    shutdown -t 10 -r

    will start a reboot after a 10 second delay. That should be plenty of time for the SSH session to end and the connection to close.

      Thanks for your reply. Yes shutdown with -r option works

      However, looks like on Fedora-18, there is no option to configure the time in seconds.

      If i try shutdown -t 10 -r, it still reboots after the default time interval of 10secs as specified in shutdown man page.

      Do you have any recommendations on how to configure the shutdown time in seconds ?

Re^3: Net-SSH-Expect & Fedora-18
by roboticus (Chancellor) on Jul 02, 2014 at 21:11 UTC

    hardy004:

    Sure, if you're using bash, you can do it like this:

    (sleep 10; ls -al) &

    The parenthesis tell bash to execute the stuff inside the parenthesis in another process, the & at the end tells it to make that process run in the background (i.e., immediately releasing the console so it can issue the next prompt). So then you'll get the next expected prompt, but the inner command will sleep for 10 seconds, and then list the directory contents. Just replace the ls command with the appropriate reboot command and you should be good to go.

    roboticus@sparky:~/tmp$ date Wed Jul 2 17:04:29 EDT 2014 roboticus@sparky:~/tmp$ (sleep 10; ls -al) & [1] 13508 roboticus@sparky:~/tmp$ date Wed Jul 2 17:04:32 EDT 2014 roboticus@sparky:~/tmp$ date Wed Jul 2 17:04:39 EDT 2014 roboticus@sparky:~/tmp$ total 144 drwxr-xr-x 2 roboticus roboticus 4096 Jun 19 11:18 . drwxr-xr-x 39 roboticus roboticus 4096 Jul 2 17:00 .. -rw-r----- 1 roboticus root 138227 Jun 12 15:30 ttt [1]+ Done ( sleep 10; ls --color=auto -al ) roboticus@sparky:~/tmp$ date Wed Jul 2 17:04:45 EDT 2014

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.