[Libssh] channel_read - Save read characters in "string"
Rico Kerster
rico.kerster at hotmail.com
Mon Jun 30 00:12:16 CEST 2008
Hello libssh-List
I successfully logged into my SSH server, can issue a command and output the comands' result to the terminal window (as in the example, I achieved that with the function "write()")
string command_output;
char cmd[] = "date\n";
BUFFER *readbuf = buffer_new();
int num = channel_write(channel,cmd,sizeof(cmd));
num = channel_read(channel,readbuf,0,0);
write(1,buffer_get(readbuf),buffer_get_len(readbuf));
But now I'd like to store the content of readbuf in the string "command_output", I studied the _M_write() template and how "write()" gets out the characters but I couldn't manage to understand and copy it. So to sum up my question:
How do I store the characters of readbuff (BUFFER) in command_output (string) or in a char[]?
Thanks in Advance.
--
Rico Kerster
_________________________________________________________________
Windows Live Messenger: Direkter Zugriff auf Ihre E-Mails! Ohne Neuanmeldung!
http://get.live.com/de-de/messenger/overview
More information about the Libssh
mailing list