0

Having read the relevant docs and tutorials and found a similar question, I am still unable to proceed. My aplogies in advance if this is a common question. I did searches but I wasn't really sure what I was looking for...

I am experimenting with the Libssh for C in Debian.

rc = ssh_channel_request_exec(channel, "ls -l");
if (rc != SSH_OK) {
  ssh_channel_close(channel);
  ssh_channel_free(channel);
  return rc;
}

This returns SSH_OK to state that the command was sent successfully. As I understand from a similar question this is because the return listens for the successful 'sending' of the command. The return does not listen to see if it has been successfully executed.

My questions is, how can I:

  • Execute the command (which by the above function presently does not execute it merely sends the command)
  • Listen for it's execution
  • print the returning output?

I am aware of the ssh_channel_read() function but as the command never executes, I usually get the output

 Read (256) buffered : 0 bytes. Window: 64000
Community
  • 1
  • 1
Chortle
  • 1
  • 1
  • Did you, as the answers in the other question, read from stderr, not just stdout, to get any potential errors ? – nos Sep 12 '13 at 11:00

1 Answers1

0

Take a look at examples/exec.c in the libssh source code!

asn
  • 798
  • 9
  • 17