[Twisted-Python] Conch: multiple commands
Brendan Simon
Brendan at BrendanSimon.com
Thu Feb 9 16:06:52 EST 2006
Gabe Rudy wrote:
> On Thursday 09 February 2006 5:37 am, Brendan Simon wrote:
>
>> The sshsimpleclient.py does send multiple commands (false, true, cat)
>> with separate channels.
>> Is that the preferred way to send multiple commands?
>> Doesn't that require some setup overhead every time I want to issue a
>> command to the server?
>>
>> Is it possible to open _one_ channel, and send commands in a
>> synchronously? ie. wait for commands to return output and then issue
>> other commands if necesary??
>> Maybe this goes against the grain of the Twisted Asynchronous Framework ???
>>
>
> The other thing to note is that each time you open a channel, you are getting
> a fresh environment. So if your series of commands depends of env vars or
> directory changes you need to do something to ensure each command is in the
> environment it expects.
>
> So instead of
> ...
> self.openChannel(CommandChannel(d, "svn co blah"))
> ...(deferred stuff)...
> self.openChannel(CommandChannel(d, "cd blah"))
> ...(deferred stuff)...
> self.openChannel(CommandChannel(d, "make"))
> ...(deferred stuff)...
> self.openChannel(CommandChannel(d, "tar -czf ../thing.tar.gz outfile"))
>
> you might want
> ...
> self.openChannel(CommandChannel(d, "svn co blah"))
> ...(deferred stuff)...
> self.openChannel(CommandChannel(d, "cd blah; make"))
> ...(deferred stuff)...
> self.openChannel(CommandChannel(d, "cd blah; tar -czf ../thing.tar.gz
> outfile"))
>
Or maybe create a script, send it to the server, (chmod it ???) and then
run it. Does that sound reasonable?
Cheers,
Brendan.
More information about the Twisted-Python
mailing list