Subject: Re: libssh2 - Shell command not being acted upon

Re: libssh2 - Shell command not being acted upon

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 25 May 2009 09:25:49 +0200 (CEST)

On Mon, 25 May 2009, Phillip Wu wrote:

> I have started using libssh2.

Welcome to our merry little corner of the universe!

> I have used ssh2.c example from the download bundle.

I'd suggest you take a look at ssh2_exec.c instead, which has been added
recently. It shows what sounds to be pretty much exactly what you're trying to
do.

> channel = libssh2_channel_open_session(session)
>
> libssh2_channel_request_pty(channel, "vanilla")

This really isn't necessary for just invoking a single command.

> libssh2_session_set_blocking(session,0);
>
> alarmclock=0;
>
> signal(SIGALRM,&alarmed);

As you're doing the operations non-blocking, it seems strange/wrong to use
signals for timeouts

> while (alarmclock==0) {
>
> libssh2_channel_read(channel,buf,sizeof(buf));
>
> sleep(1);
>
> }

This is of course highly ineffective, but I presume you know this.

-- 
  / daniel.haxx.se
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2009-05-25