开发者

Using a channel for multiple commands, replys, and interactive commands?

I'm beginning to learn twisted.conch to automate some tasks over SSH.

I tried to modify the sample sshclient.py from http://www.devshed.com/c/a/Python/SSH-with-Twisted/4/ . It runs 1 command after login and prints captured output.

What I wanted to do is to run a series commands, and maybe decide what to do based on the output.

The problem I ran into is that twisted.conch.ssh.channel.SSHChannel appears to be always closing itself after running a command (such as df -h). The example will sendRequest after channelOpen. Then the channel is always closed after dataReceived no matter what I did.

I'm wondering if this is due to server sending an EOF after the command. And therefore this channel must be closed? Should I just open multiple channels for multiple commands?

Another problem is those interactive commands (such as rm -i somefile). It seems that because the server didn't send EOF, SSHChannel.dataReceived never gets called.开发者_StackOverflow中文版 How do I manage to capture output in this situation, and what do I do to send back a response?


Should I just open multiple channels for multiple commands?

Yep. That's how SSH works.

SSHChannel.dataReceived never gets called

This doesn't sound like what should happen. Perhaps you can include a minimal example which reproduces the behavior.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜