Subject: Re: [libssh2] (no subject)

Re: [libssh2] (no subject)

From: Paul Thomas <thomaspu_at_gmail.com>
Date: Sun, 9 Sep 2007 01:26:19 -0400

The problem that I have isn't that I don't know how to read and write stuff
to my ssh connection, its that after setting up a shell, I don't get
anything over the socket.

        if (libssh2_channel_request_pty(m_channel, "vt100")) {
            log( "Failed requesting pty");
        }

        if (libssh2_channel_shell(m_channel)) {
            log( "Unable to request shell on allocated pty");
        }

        if ( libssh2_poll_channel_read(m_channel, 0) )
            log("hey, theres data");

        libssh2_channel_write(m_channel, "/bin/bash\r\n",
strlen("/bin/bash\r\n"));

        if ( libssh2_poll_channel_read(m_channel, 0) )
            log("hey, theres data");

So after getting a shell on a pty, I'd expect that there be some data
waiting to be read from the socket.. like the prompt:
   user_at_computername $
But there's nothing. So I tried to startup a terminal and then read from the
channel and still no data. How do I tell it to fire up a terminal on the
remote end? Or how do I get the default prompt?

Thanks,
Paul

On 9/9/07, Mark Erikson <mark_at_isquaredsoftware.com> wrote:
>
> > From: "Paul Thomas" <thomaspu_at_gmail.com>
> > Subject: [libssh2] Interacting with a shell how?
> >
> > So I've been reading through the docs and I've got a working example
> that
> > can get to the point where it can open up a shell on a pty, but after
> that
> > suceeds what do I do now?
> >
> > The guides all say
> > /* At this point the shell can be interacted with using
> > * libssh2_channel_read()
> > * libssh2_channel_read_stderr()
> > * libssh2_channel_write()
> > * libssh2_channel_write_stderr()
> >
> > Thats nice, but I expected that after I requested a shell that there
> would
> > be some data on the socket ready to be read that contained something
> like:
> > paul_at_computerName ~ $
> >
> > What am I missing here? I've been unable to find much help online in the
> > form of docs talking about ssh with the exception of the RFCs and these
> talk
> > about the protocol, not what do do when its already connected.
> >
> > Help? Advice?
> > Paul
>
> I've also been working on a project which uses libssh2 to create a
> shell. I don't have a good, simple example to give you, since it's a
> GUI program that contains code adapted from several different sources,
> and things are ugly right now. But, let me see if I can give an
> overview of how I've got things working.
>
> I have an SSHConnection class that encapsulates the socket IO. Whenever
> the socket reports that there's input available, I call
> SSHConnection->Read(void * buffer, uint nbytes). Read() does some
> calculations to figure out exactly how much to read from the channel,
> does a libssh2_poll() to confirm that it's ready to read, then creates a
> new char[] buffer and calls libssh2_channel_read(channel, buffer,
> actualNBytes). From there, you should be able to do whatever you want
> with the data.
>
> Writing's pretty simple. Whenever the user types, I call
> SSHConnection->Write(char* data, int len), which passes it on to
> libssh2_channel_write(channel, data, len).
>
> My project is still pretty much a throwaway test with a lot of glitches,
> so I don't claim to have this perfected. Still, hopefully that will
> give you a bit of an idea where to head.
>
> Mark Erikson
> http://www.isquaredsoftware.com
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> libssh2-devel mailing list
> libssh2-devel_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libssh2-devel
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2007-09-09