Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Net-SSH-Expect & Fedora-18

by roboticus (Chancellor)
on Jul 02, 2014 at 00:12 UTC ( [id://1091922]=note: print w/replies, xml ) Need Help??


in reply to Net-SSH-Expect & Fedora-18

hardy004:

Perhaps Fedora 14 didn't terminate the TCP connections on reboot while Fedora 18 does? Or maybe there's a difference in the shutdown script for ssh.

In any event, I'd either:

  • Use shutdown instead of reboot, providing enough time delay to process the next prompt,
  • Catching the error when you run reboot and discard it,
  • Make a small shell script that performs the reboot in the background after a time delay.

...roboticus

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

Replies are listed 'Best First'.
Re^2: Net-SSH-Expect & Fedora-18
by hardy004 (Novice) on Jul 02, 2014 at 02:55 UTC

    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

      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 ?

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1091922]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 05:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found