Subject: Re: libssh2_channel_read issues

Re: libssh2_channel_read issues

From: Henrik Nordström <>
Date: Fri, 13 Apr 2012 23:56:15 +0200

fre 2012-04-13 klockan 09:39 +0100 skrev Zulfiqar Malik:

> My understanding was that the EOF was completely incorrect it seems.
> That's fine. I think I really should be using libssh2_channel_exec.

Why do you think libssh2_channel_exec is the right one for you?

> However, I have a slight problem. I think exec only allows you to
> exec one command and then you have to recreate the channel if you wish
> to exec another one.

Yes. libssh2_channel_exec requests the exec service type. This service
type is for executing a single command.

If you want to execute multiple commands then a shell service is more

> This is a bit of a problem for me since our remote cluster setup
> requires you to specify the name of the specific host that you wish to
> connect to after you've connected to the main server. I don't know how
> to give this information in one go to libssh2 so that I can then exec
> the command of my choice and be done with it.

How is that specified?

How would you do it when using for example openssh ssh command?

libssh2_channel_exec() is the equivalence of

   ssh -T hostname command

compared to libssh_channel_shell() which is more similar to

   ssh -T hostname

and then give the desired command(s) as input.


Received on 2012-04-13