[Twisted-Python] Conch SSH help?

Nick Arnett narnett at liveworld.com
Thu Jun 16 18:25:46 EDT 2005

I'm getting stuck trying to do something I imagined would be easy in 
Conch.  I want to log into a server, ls a directory, then grep inside a 
certain file in each of the directories found by the ls command.

I've had no trouble logging in and running ls, then capturing its 
output.  But then I'm stuck.  I can't figure out where to put the loop 
through the directories.  I can see how to do one in a new channel, but 
I sure can't see how to run the series of them and capture their 
output.  I want to end up with a data structure that has the directory 
name and the results of the grep as a list: [(dir, grep_results),...].

I've tried calling my "grep" channel object repeatedly and that sort of 
works, but only does the first seven or eight and fails.  I've tried 
putting the loop in the channelOpen method of the "grep" channel and 
that never gets any results.  I tried building a series of callbacks in 
there and running it, but that doesn't work, either.

What I also find confusing is that I run the command with sendRequest, 
but the results come back in the dataReceived method -- how does it know 
which command's results it is receiving?

Any help will be appreciated.


More information about the Twisted-Python mailing list