[Twisted-Python] sending 'tail -f' command to a remote host using conch?
Harsha
nharsha at gmail.com
Mon Aug 10 00:10:41 MDT 2009
Hi All,
A day back I install Twisted and Conch on RHEL5. I am a novice user of
Twisted software.
I copied an example from dev-shed website (attached herewith). This example
script uses conch to talk to a ssh deamon.
This script was able to capture and return the output of simple commands
such as - ls, cat etc.
I mean, when I run the script to execute 'ls -al' on a remote machine it
does and returns the prompt.
Where as, when I run the script to execute '*tail -f /path/to/mylog.txt*' I
get the ouput of this command but the prompt never returns.
When I press ^C (Control-C) I get the following run-time error.
*Traceback (most recent call last):
File
"/usr/lib/python2.4/site-packages/Twisted-8.2.0-py2.4-linux-i686.egg/twisted/internet/tcp.py",
line 520, in connectionLost
protocol.connectionLost(reason)
File
"/usr/lib/python2.4/site-packages/Twisted-8.2.0-py2.4-linux-i686.egg/twisted/conch/ssh/transport.py",
line 166, in connectionLost
self.service.serviceStopped()
File
"/usr/lib/python2.4/site-packages/Twisted-8.2.0-py2.4-linux-i686.egg/twisted/conch/ssh/connection.py",
line 59, in serviceStopped
map(self.channelClosed, self.channels.values())
File
"/usr/lib/python2.4/site-packages/Twisted-8.2.0-py2.4-linux-i686.egg/twisted/conch/ssh/connection.py",
line 580, in channelClosed
log.callWithLogger(channel, channel.closed)
--- <exception caught here> ---
File
"/usr/lib/python2.4/site-packages/Twisted-8.2.0-py2.4-linux-i686.egg/twisted/python/log.py",
line 84, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File
"/usr/lib/python2.4/site-packages/Twisted-8.2.0-py2.4-linux-i686.egg/twisted/python/log.py",
line 69, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File
"/usr/lib/python2.4/site-packages/Twisted-8.2.0-py2.4-linux-i686.egg/twisted/python/context.py",
line 59, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File
"/usr/lib/python2.4/site-packages/Twisted-8.2.0-py2.4-linux-i686.egg/twisted/python/context.py",
line 37, in callWithContext
return func(*args,**kw)
File "shankha.py", line 56, in closed
reactor.stop()
File
"/usr/lib/python2.4/site-packages/Twisted-8.2.0-py2.4-linux-i686.egg/twisted/internet/base.py",
line 526, in stop
raise error.ReactorNotRunning(
twisted.internet.error.ReactorNotRunning: Can't stop reactor that isn't
running.*
*I know that 'tail -f' command is expecting "Control-C" or Break to return
the prompt on remote host.
But my attempt to send the ^C character is failing..
I am doing somethink like this:
python sshc.py <hostname> 'tail -f mylog.txt ; \x03'
What is the recommended method to adopt such cases?
*Cheers!!
Harsha Reddy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20090810/0dcc2764/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sshc.py
Type: text/x-python
Size: 2626 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20090810/0dcc2764/attachment-0002.py>
More information about the Twisted-Python
mailing list