[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Getting error string from a failed ssh command
[Thread Prev] | [Thread Next]
[Date Prev] | [Date Next]
- Subject: Getting error string from a failed ssh command
- From: Norm Green <norm.green@xxxxxxxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Mon, 3 Oct 2022 15:36:15 -0700
- To: libssh@xxxxxxxxxx
Hello libssh list, If I run a command over ssh that fails from the Linux command line: normg@moop>ssh hood foo bash: foo: command not found normg@moop>echo $? 127I get an error string ("bash: foo: command not found") and an error code (127). For example:
My question is how to do the equivalent with libssh ? If I do this after opening a session and a channel: int rc = ssh_channel_request_exec(sshChannel, "foo"); int bytesReady = ssh_channel_poll_timeout(sshChannel, timeout, FALSE); returns -127 and: int numRead = ssh_channel_read_timeout(sshChannel, resultBuffer.nextWriteByte(), (int) resultBuffer.bytesFree(), 0, // timeout: block in poll, not here 0); returns 0, so I don't get the error string back from libssh. How can I get the error string result from the failed command using libssh ? Norm GreenP.S.: If the command succeeds (rc == 0) then everything works and I get the result string back as expected.
Re: Getting error string from a failed ssh command | Jakub Jelen <jjelen@xxxxxxxxxx> |