Subject: Re: libssh2_channel_read issues

Re: libssh2_channel_read issues

From: Zulfiqar Malik <zulfiqar.malik_at_gmail.com>
Date: Fri, 13 Apr 2012 09:39:16 +0100

Hi,

My understanding was that the EOF was completely incorrect it seems. That's
fine. I think I really should be using libssh2_channel_exec. 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. 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.

I might be missing something very basic here or maybe this isn't possible
at all. Thanks for the help.

On Thu, Apr 12, 2012 at 3:49 PM, Peter Stuge <peter_at_stuge.se> wrote:

> Hi.
>
> Zulfiqar Malik wrote:
> > I am actually using libssh2_channel_write. I am basically just doing a cd
> > <somedir> and then reading the output. The cd finishes and yet I am stuck
> > in my loop since I never receive an EOF.
>
> Seriously. You need to think about what is actually happening on the
> server side.
>
> Now, you do not say which kind of channel you have created, which is
> absolutely neccessary information when you are asking about behavior
> within a channel. However, since you start talking about shell I am
> going to guess that you have created a shell channel.
>
> If you start a shell *without* ssh and you run a cd command in that
> shell does that shell close it's input and output channels? Obviously
> it does not. That would be the most retarded shell ever.
>
> Since you do not get an EOF when running the shell without ssh WHY
> would get an EOF *with* SSH?
>
> There is NO difference.
>
> SSH provides an authenticated and encrypted transport to a server.
>
> In this transport you can open various types of channels. Each
> channel type may have completely different characteristics. If you
> open a shell channel then it will behave EXACTLY like a shell running
> without SSH.
>
> Your program is talking to a shell, nothing more nothing less.
> libssh2 is not an API for remote controlling shells. I wish that
> people would understand this, there are countless posts to this
> mailing list by people who do not understand this at all. We
> desperately need to write a FAQ about it.
>
>
> > I can use waitsocket. The Sleep is just test code. waitsocket
> > doesn't imrpove the situation.
>
> Seriously. There are several examples in the example/ directory
> which demonstrate how you can correctly deal with multiple sources
> of input in your program, which I believe is what you want to do
> although you don't say it.
>
> Please study those examples. In particular you want to study
> direct_tcpip.c and tcpip-forward.c in detail.
>
>
> //Peter
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
>

-- 
Regards,
Zulfiqar Inayat Malik.

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2012-04-13