[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Multiple calls to channel_request_exec()
[Thread Prev] | [Thread Next]
- Subject: Re: Multiple calls to channel_request_exec()
- From: Stephan Kountso <steplg@xxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Thu, 25 Feb 2010 12:13:59 +0300
- To: libssh@xxxxxxxxxx
in fact, no (read http://dev.libssh.org/doxygen/group__ssh__channel.html#ga2fde5b778179983f583c6b250057e278). So, after the command has been executed, channel is closed and you need to open new channel to execute new command. So, you can't for example execute su another user with a channel_request_exec, and then some another command under the another user. i have similar task and i use channel_request_shell. to communicate with serever. The only problem with this way is than prompt could change during the shell session and you must know shell prompt before you begin communication. for my project i wrote simple c++ libssh wrapper to solve all these problems. On Thu, Feb 25, 2010 at 3:26 AM, Mark Hessling <mark@xxxxxxxx> wrote: > I'm looking at libssh to enable the replacement of an existing > application that uses raw sockets to control a telnet session. In future > the connection must be done using ssh. > > I tried modifying examples/exec.c and duplicated the block of code that > calls channel_request_exec() to execute "ps aux" and to read the output. > I simply added a call to channel_request_exec() to execute "ls -l", but > I received an error: "Channel exec request failed". > > Should I be able to with libssh, execute a shell command on the remote > host, read its output and execute another shell command and read its > output? > > >From my reading of the documentation it appears that each call to > channel_request_exec() spawns another shell on the remote server, so if > I wanted to execute the following on the remote server: > "cd tmp" > "./run_my_command" > then the second command would not be executed in the "tmp" directory. > > Does libssh then need a "changedirectory" function similar to the one > that sets environment variables? > > Thanks in advance for your responses. > > -- > > * Mark Hessling, mark@xxxxxxxx http://www.rexx.org/ > * Author of THE, a Free XEDIT/KEDIT editor, Rexx/SQL, Rexx/CURL, etc. > * Maintainer of Regina Rexx interpreter and Rexx/Tk > * Use Rexx? join the Rexx Language Association: http://www.rexxla.org/ > > > -- С уважением, Кунцьо Степан aka StepLg
Multiple calls to channel_request_exec() | Mark Hessling <mark@xxxxxxxx> |