[paramiko] ctrl-c issue.
Christian Vest Hansen
karmazilla at gmail.com
Sat Jan 5 15:03:05 PST 2008
Hi,
I have this issue, that when I connect to a server and exec_command on
something that'll take a long time to finish, if ever (like tail -f),
my script will only be able to respond to my local ctrl-c commands
when the remote program produces output.
This is the example program I use:
=================================================
import sys
import getpass
import paramiko
client = paramiko.SSHClient()
try:
client.load_system_host_keys()
hostname = raw_input("Hostname: ")
port = 22
username = raw_input("Username: ")
password = getpass.getpass()
client.connect(hostname, port, username, password)
cmd = raw_input("[%s@%s]$ " % (username, hostname))
stdin, stdout, stderr = client.exec_command(cmd)
for line in stdout:
print line,
except:
sys.excepthook(*sys.exc_info())
finally:
client.close()
=================================================
Steps to reproduce:
* connect to some server with normal ssh and $echo a >> my_file
* then use above program to connect to the same server and run $tail -f my_file
* then $echo b >> my_file and see the tail working
* then, in the shell with above program still running, press ctrl-c
* notice that pressing ctrl-c dosn't stop above program, regardless of
how long you wait
* now, in the normal ssh, do $echo c >> my_file
* only then will above program notice the term request and halt operation
What I want is for the program to terminate immediately when I press
ctrl-c, so the question is how I can I make this so?
--
Venlig hilsen / Kind regards,
Christian Vest Hansen.
More information about the paramiko
mailing list