[Twisted-Python] How to ... in Conch?
1) I want to invoke(exec) a command with arguments from a SSH Conch client. The example suggests that arguments should be passed along with command, so to invoke 'ls -l', one would pass common.NS('ls -l'). What to do about arguments that have spaces? Should I slash-escape them? 2) How to obtain the retcode from an exec'ed command? -- Konrads Smelkovs Applied IT sorcery.
On 9/8/07, Konrads Smelkovs <konrads.smelkovs@gmail.com> wrote:
1) I want to invoke(exec) a command with arguments from a SSH Conch client. The example suggests that arguments should be passed along with command, so to invoke 'ls -l', one would pass common.NS('ls -l'). What to do about arguments that have spaces? Should I slash-escape them?
Commands are executed with the -e argument of your shell. You can slash-escape spaces or quote them; either one should work.
2) How to obtain the retcode from an exec'ed command?
If the server supports it, it sends a 'exit-status' request to the channel with a uint32 encoded exit code. If it exits with a signal, an 'exit-signal' message is sent with format: string signal name bool core dumped string error message string language HTH, -p
Hello, How to obtain the stderror? chanel.SSHChannel has an interesting method extReceived, is it that? On 9/8/07, Paul Swartz <paulswartz@gmail.com> wrote:
On 9/8/07, Konrads Smelkovs <konrads.smelkovs@gmail.com> wrote:
1) I want to invoke(exec) a command with arguments from a SSH Conch client. The example suggests that arguments should be passed along with command, so to invoke 'ls -l', one would pass common.NS('ls -l'). What to do about arguments that have spaces? Should I slash-escape them?
Commands are executed with the -e argument of your shell. You can slash-escape spaces or quote them; either one should work.
2) How to obtain the retcode from an exec'ed command?
If the server supports it, it sends a 'exit-status' request to the channel with a uint32 encoded exit code. If it exits with a signal, an 'exit-signal' message is sent with format: string signal name bool core dumped string error message string language
HTH, -p
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Konrads Smelkovs Applied IT sorcery.
I seem to have figured it out. Attached is a module with function executeCommand that executes a single command, gathers input, output and error code and returns it. Comment at will. On 9/9/07, Konrads Smelkovs <konrads.smelkovs@gmail.com> wrote:
Hello,
How to obtain the stderror? chanel.SSHChannel has an interesting method extReceived, is it that?
On 9/8/07, Paul Swartz <paulswartz@gmail.com > wrote:
On 9/8/07, Konrads Smelkovs < konrads.smelkovs@gmail.com> wrote:
1) I want to invoke(exec) a command with arguments from a SSH Conch client. The example suggests that arguments should be passed along with command, so to invoke 'ls -l', one would pass common.NS('ls -l'). What to do about arguments that have spaces? Should I slash-escape them?
Commands are executed with the -e argument of your shell. You can slash-escape spaces or quote them; either one should work.
2) How to obtain the retcode from an exec'ed command?
If the server supports it, it sends a 'exit-status' request to the channel with a uint32 encoded exit code. If it exits with a signal, an 'exit-signal' message is sent with format: string signal name bool core dumped string error message string language
HTH, -p
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Konrads Smelkovs Applied IT sorcery.
-- Konrads Smelkovs Applied IT sorcery.
On 9/9/07, Konrads Smelkovs <konrads.smelkovs@gmail.com> wrote:
I seem to have figured it out. Attached is a module with function executeCommand that executes a single command, gathers input, output and error code and returns it. Comment at will.
A couple comments: * extReceived() should probably check that the data type is correct (connection.EXTENDED_DATA_STDERR) and append the extended data rather than overwriting the previous data. * closed() should check that self.exitcode is present. Like I mentioned earlier, if the process ends with a signal, the server will send exit-signal. -p -- Paul Swartz paulswartz at gmail dot com http://z3p.livejournal.com/ AIM: z3penguin
participants (2)
-
Konrads Smelkovs -
Paul Swartz