how to keepalive ssh connect with long duration command

1,473 views
Skip to first unread message

ZHANG Jiaqiang A

unread,
Apr 18, 2012, 10:19:07 AM4/18/12
to robotframe...@googlegroups.com
Hi All,
 
I would like to know if there is anyway to keep the ssh connection alive while it execute some script remotely ?
 
If you're using SSH lib ? The remote server (or rounter) will disconnect any inactive conn before my script finish.
 
Best regards,
Zhang Jiaqiang

Mathieu Bultel

unread,
Apr 18, 2012, 11:31:17 AM4/18/12
to robotframe...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To post to this group, send email to robotframe...@googlegroups.com.
To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.
Hi,

I have to launch some script shell on remote server too. I initialize the connection with the keyword "open connection" and "login". Then, I launch the script with the keyword "write". This keyword wirte the command and append a new line on the current channel. Then I use the keyword, "Read Until Prompt", in order to read the output of the command and return it in a variable.

If your script take long time, I advise you to set the timeout before write your command.

The sshlibrary is very simple to use, just have a look on the paramiko documentation for understand all the tricks : http://www.lag.net/paramiko/docs/paramiko.SSHClient-class.html

Best regards,
Mat.







Tatu Aalto

unread,
Apr 18, 2012, 12:27:59 PM4/18/12
to robotframe...@googlegroups.com
Ugh

I am assuming that you run this script on *nix platform.  If the script does not produce output, or one wants to redirect the output to a file, one could use the nohup[1] to start the script in the background. Wait and verify that it has finished the job and grab the result.

-Tatu
[1] http://en.wikipedia.org/wiki/Nohup

ZHANG Jiaqiang A

unread,
Apr 18, 2012, 10:19:55 PM4/18/12
to mat.b...@gmail.com, robotframe...@googlegroups.com
Hello,
 
Thanks for the answer. But I am still confused:
 
Imagine your remote *nix server will disconnect any idle client and terminating the session if no data has been received from client longer than 5 min. But your script on remote server will take 10 min to finish.
 
Can SSH lib deal with this scenario ?
(With putty client, there is an option "Sending of null packets to keep session active".)
 
Best regards,
Zhang Jiaqiang


From: robotframe...@googlegroups.com [mailto:robotframe...@googlegroups.com] On Behalf Of Mathieu Bultel
Sent: Wednesday, April 18, 2012 11:31 PM
To: robotframe...@googlegroups.com
Subject: Re: how to keepalive ssh connect with long duration command

Reply all
Reply to author
Forward
0 new messages