Hi,Peter,

 My comments after //.
 And main codes at the end of mail.

    Thanks.

[email protected] wrote:
 But command "ls -l", just response "ls -". (all of them I had
added line feed after command string)
 The same server, the same shell commands, putty works well.

So use PuTTY?
//No, I use PuTTY just verify the ssh server works well and the problem
occurs at my application side.

Seriously, I am confident that all your shell problems are because
you are trying to control it from software, when in fact it was
designed to be controlled by a user.
//My application is not so complicated as you think. It just need execute
some shell command. Later I will paste a snap and the main codes.

As far as I can see, libssh2 is working correctly for you. There is
some problem in your application logic. The libssh2 community is not
a good place to ask questions about how to programmatically control a
shell.

If you insist on trying to control a typical shell from your
application you should study shells in general in depth, your
targeted shell in particular depth, and terminal emulation in your
targeted server system also in depth. You need to understand every
part of every piece of software that is involved in the normal
environment where a shell receives commands - ie. when a user is
working with it. This is quite a big task!

If you are not interested in learning all that, I would suggest
looking into other ways of executing commands the way you want.

You have not explained what you want to develop using libssh2 so we
can't really help with any further suggestions.


 Could you take a look at my problem?

No. You have not presented anything that anyone can look at. No log
files, no source code, no debug output, nothing beyond your retyped
observations.


Alexander Lamaison wrote:
Please post code!  Even if it's just a few lines showing what you
are doing (however a minimal working example that reproduces the
problem is much preferred).

Please always send a minimal example. That shows everyone on the
mailing list that you are in fact prepared to do a bit of work
yourself, in order to solve your problem. If you are not, noone else
will be interested in helping you either.


Code speaks louder than words: there is no ambiguity and nothing
gets lost in translation.

Yes, this is very true.


Bill, if you require someone to EXTRACT information from you (as we
have had to do so far) then you can not expect to get help from the
open source community.

You need to be very active and PUSH the correct information into the
community so that you make it as easy as possible for a kind person
to help you.

Even then, you can never assume to get help. There is simply no
guarantee. If that is unacceptable then maybe look for a commercial
source of support.


//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel



  Part 1.  Open a shell( Most of them same to codes of "libss2.c" )

   .....
   .....

   channel = libssh2_channel_open_session(session);

   /* Some environment variables may be set,
    * It's up to the server which ones it'll allow though
    */
   libssh2_channel_setenv(channel, "FOO", "bar");

   /* Request a terminal with 'vanilla' terminal emulation
    * See /etc/termcap for more options
    */

   rc = libssh2_channel_request_pty(channel, "vanilla");
   rc = libssh2_channel_shell(channel);
   Sleep(300);

   char buffer[1024];
   memset(buffer, '\0', 1024);
   QString recvData;


   rc = libssh2_channel_read( channel, buffer, sizeof(buffer));
   if( rc > 0 )
   {
       recvData = tr(buffer);
       ui->textEdit->append(recvData);
       recvData.clear();
       memset(buffer, '\0', 1024);
   }

Part 2. enter commands
void Dialog::lineReturnPressed()
{
   char buffer[4096];
   memset(buffer, '\0', 4096);
   QString recvData;

   QString testcmd =ui->lineEdit->text()+"\r\n";
   
libssh2_channel_write(channel,testcmd.toStdString().c_str(),sizeof(testcmd.toStdString().c_str()));
   Sleep(1000);

   int  rc = libssh2_channel_read( channel, buffer, sizeof(buffer));
   if( rc > 0 )
   {
       recvData = tr(buffer);
       ui->textEdit->append(recvData);
       recvData.clear();
       memset(buffer, '\0', 4096);
   }
   ui->lineEdit->clear();
}




--------------------------------------------------
From: "Peter Stuge" <[email protected]>
Sent: Tuesday, September 22, 2009 11:32 PM
To: "libssh2 development" <[email protected]>
Subject: Re: using ssh2  on linux shell

[email protected] wrote:
 But command "ls -l", just response "ls -". (all of them I had
added line feed after command string)
 The same server, the same shell commands, putty works well.

So use PuTTY?

Seriously, I am confident that all your shell problems are because
you are trying to control it from software, when in fact it was
designed to be controlled by a user.

As far as I can see, libssh2 is working correctly for you. There is
some problem in your application logic. The libssh2 community is not
a good place to ask questions about how to programmatically control a
shell.

If you insist on trying to control a typical shell from your
application you should study shells in general in depth, your
targeted shell in particular depth, and terminal emulation in your
targeted server system also in depth. You need to understand every
part of every piece of software that is involved in the normal
environment where a shell receives commands - ie. when a user is
working with it. This is quite a big task!

If you are not interested in learning all that, I would suggest
looking into other ways of executing commands the way you want.

You have not explained what you want to develop using libssh2 so we
can't really help with any further suggestions.


 Could you take a look at my problem?

No. You have not presented anything that anyone can look at. No log
files, no source code, no debug output, nothing beyond your retyped
observations.


Alexander Lamaison wrote:
Please post code!  Even if it's just a few lines showing what you
are doing (however a minimal working example that reproduces the
problem is much preferred).

Please always send a minimal example. That shows everyone on the
mailing list that you are in fact prepared to do a bit of work
yourself, in order to solve your problem. If you are not, noone else
will be interested in helping you either.


Code speaks louder than words: there is no ambiguity and nothing
gets lost in translation.

Yes, this is very true.


Bill, if you require someone to EXTRACT information from you (as we
have had to do so far) then you can not expect to get help from the
open source community.

You need to be very active and PUSH the correct information into the
community so that you make it as easy as possible for a kind person
to help you.

Even then, you can never assume to get help. There is simply no
guarantee. If that is unacceptable then maybe look for a commercial
source of support.


//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Reply via email to