[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libssh2-devel
Subject:    Re: [libssh2] (no subject)
From:       "Paul Thomas" <thomaspu () gmail ! com>
Date:       2007-09-10 16:51:37
Message-ID: c52222ba0709100951n7eb524a8q6d81c4d403ac0d14 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


So I take it no one out there has any idea how to actually get things going
with this library? I can create the shell..now what? Why isn't there a bash
like prompt being sent back to me over the socket?

On 9/9/07, Paul Thomas <thomaspu@gmail.com> wrote:
>
> 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@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@isquaredsoftware.com> wrote:
> >
> > > From: "Paul Thomas" <thomaspu@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@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@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/libssh2-devel
> >
>
>

[Attachment #5 (text/html)]

So I take it no one out there has any idea how to actually get things going with this library? I can \
create the shell..now what? Why isn&#39;t there a bash like prompt being sent back to me over the \
socket?<br><br><div><span class="gmail_quote"> On 9/9/07, <b class="gmail_sendername">Paul Thomas</b> \
&lt;<a href="mailto:thomaspu@gmail.com">thomaspu@gmail.com</a>&gt; wrote:</span><blockquote \
class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; \
padding-left: 1ex;"> The problem that I have isn&#39;t that I don&#39;t know how to read and write stuff \
to my ssh connection, its that after setting up a shell, I don&#39;t get anything over the \
socket.<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (libssh2_channel_request_pty(m_channel, \
&quot;vt100&quot;)) { <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; log( &quot;Failed \
requesting pty&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; if (libssh2_channel_shell(m_channel)) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; log( &quot;Unable to request shell on allocated pty&quot;);<br>&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; }<br><br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( \
libssh2_poll_channel_read(m_channel, 0) ) <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; log(&quot;hey, theres \
data&quot;);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; libssh2_channel_write(m_channel, \
&quot;/bin/bash\r\n&quot;, strlen(&quot;/bin/bash\r\n&quot;));<br><br>&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; if ( libssh2_poll_channel_read(m_channel, 0) )<br>

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; log(&quot;hey, theres data&quot;);<br><br>So \
after getting a shell on a pty, I&#39;d expect that there be some data waiting to be read from the \
socket.. like the prompt:<br>&nbsp;&nbsp; user@computername $<br>But there&#39;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? <br><br>Thanks,<br><span \
class="sg">Paul</span><div><span class="e" id="q_114e8bb8e336689e_2"><br><br><div><span \
class="gmail_quote">On 9/9/07, <b class="gmail_sendername">Mark Erikson</b> &lt;<a \
href="mailto:mark@isquaredsoftware.com" target="_blank" onclick="return \
top.js.OpenExtLink(window,event,this)"> mark@isquaredsoftware.com</a>&gt; wrote:</span><blockquote \
class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; \
padding-left: 1ex;"> &gt; From: &quot;Paul Thomas&quot; &lt;<a href="mailto:thomaspu@gmail.com" \
target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">thomaspu@gmail.com</a>&gt;<br>&gt; \
Subject: [libssh2] Interacting with a shell how? <br>&gt;<br>&gt; So I&#39;ve been reading through the \
docs and I&#39;ve got a working example that <br>&gt; can get to the point where it can open up a shell \
on a pty, but after that<br>&gt; suceeds what do I do now?<br>&gt;<br>&gt; The guides all \
say<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; /* At this point the shell can be interacted with using <br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* \
libssh2_channel_read()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* \
libssh2_channel_read_stderr()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* \
libssh2_channel_write()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* \
libssh2_channel_write_stderr()<br>&gt;<br>&gt; Thats nice, but I expected that after I requested a shell \
that there would <br>&gt; be some data on the socket ready to be read that contained something \
like:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;paul@computerName ~ $<br>&gt;<br>&gt; What am I missing here? \
I&#39;ve been unable to find much help online in the<br>&gt; form of docs talking about ssh with the \
exception of the RFCs and these talk <br>&gt; about the protocol, not what do do when its already \
connected.<br>&gt;<br>&gt; Help? Advice?<br>&gt; Paul<br><br>I&#39;ve also been working on a project \
which uses libssh2 to create a<br>shell.&nbsp;&nbsp;I don&#39;t have a good, simple example to give you, \
since it&#39;s a <br>GUI program that contains code adapted from several different sources,<br>and things \
are ugly right now.&nbsp;&nbsp;But, let me see if I can give an<br>overview of how I&#39;ve got things \
working.<br><br>I have an SSHConnection class that encapsulates the socket IO.&nbsp;&nbsp;Whenever \
<br>the socket reports that there&#39;s input available, I call<br>SSHConnection-&gt;Read(void * buffer, \
uint nbytes).&nbsp;&nbsp;Read() does some<br>calculations to figure out exactly how much to read from the \
channel,<br>does a libssh2_poll() to confirm that it&#39;s ready to read, then creates a <br>new char[] \
buffer and calls libssh2_channel_read(channel, buffer,<br>actualNBytes).&nbsp;&nbsp;From there, you \
should be able to do whatever you want<br>with the data.<br><br>Writing&#39;s pretty \
simple.&nbsp;&nbsp;Whenever the user types, I call <br>SSHConnection-&gt;Write(char* data, int len), \
which passes it on to<br>libssh2_channel_write(channel, data, len).<br><br>My project is still pretty \
much a throwaway test with a lot of glitches,<br>so I don&#39;t claim to have this \
perfected.&nbsp;&nbsp;Still, hopefully that will <br>give you a bit of an idea where to head.<br><br>Mark \
Erikson<br><a href="http://www.isquaredsoftware.com" target="_blank" onclick="return \
top.js.OpenExtLink(window,event,this)">http://www.isquaredsoftware.com</a><br> \
<br>------------------------------------------------------------------------- <br>This SF.net email is \
sponsored by: Microsoft<br>Defy all challenges. Microsoft(R) Visual Studio 2005.<br><a \
href="http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/" target="_blank" onclick="return \
top.js.OpenExtLink(window,event,this)"> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
</a><br>_______________________________________________<br>libssh2-devel mailing list<br><a \
href="mailto:libssh2-devel@lists.sourceforge.net" target="_blank" onclick="return \
top.js.OpenExtLink(window,event,this)">libssh2-devel@lists.sourceforge.net </a><br><a \
href="https://lists.sourceforge.net/lists/listinfo/libssh2-devel" target="_blank" onclick="return \
top.js.OpenExtLink(window,event,this)"> \
https://lists.sourceforge.net/lists/listinfo/libssh2-devel</a><br></blockquote></div><br> \
</span></div></blockquote></div><br>



-------------------------------------------------------------------------
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic