[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting mkdir command result


When using ssh_channel_request_exec, it always returned success even if
mkdir fails and no error identified in ssh_get_error.

But setting stderr to 1 and parsing returned buffer, resolves my problem.

Many Thanks!

Regards,
Nikhil

On Wed, Jan 12, 2011 at 2:35 PM, Aris Adamantiadis <aris@xxxxxxxxxxxx>wrote:

> Le 12/01/11 08:08, Nikhil Agrawal a écrit :
> > Hi,
> >
> > I am using libssh to run mkdir on remote machine. In case mkdir fails, I
> > want to receive/get error in my client so i can take measures. I am
> > getting OK as return code in all cases and don’t get to know if mkdir
> > successfully ran or not. Please Suggest.
> >
> > Thanks!
> >
> >
> Hi Nikhil,
>
> I suggest that you check the return code, either using Rocky's method,
> or by using ssh_channel_get_exit_status() (you may have to wait that the
> channel is closed for this).
> You can check in the stderr stream
> (ssh_channel_read(channel,dest,len,1); since the error message of mkdir
> will be written to stderr and not stdout.
>
> Another solution, that I really advise you use, is to use the sftp
> subsystem which has reliable functions to manipulate remote filesystems.
>
> Kind regards,
>
> Aris
>
>

Follow-Ups:
Re: Getting mkdir command resultAris Adamantiadis <aris@xxxxxxxxxxxx>
References:
Getting mkdir command resultNikhil Agrawal <mrnikhilagrawal@xxxxxxxxx>
Re: Getting mkdir command resultAris Adamantiadis <aris@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org