Hi,
I call libssh2_channel_exec with the 'date' command and a subsequent
call
to libssh2_channel_read returns the output of the 'date' command as
expected.
However if I add a sftp session prior to the libssh2_channel_exec with
the 'date' command then the
libssh2_channel_read returns no data.
Is this related to problem 2785173 - "channel_read returns
LIBSSH2_ERROR_EAGAIN, no data on socket"
which seems to have been closed. When a bug is closed when is the fix
available?
The code segments shown below is AFTER successful authentication. I set
an 'alarm' to terminate
the read sequence.
This code works OK:
/* exec date */
status = libssh2_channel_exec(channel, "/bin/date");
/* Read output */
p=buf;
signal(SIGALRM,&alarmed);
alarm(120);
alarmclock=0;
while (alarmclock==0) {
status = libssh2_channel_read( channel, p,buf+sizeof(buf)-p);
if (status<=0) {
switch (status) {
case 0:
break;
case LIBSSH2_ERROR_EAGAIN:
break;
case LIBSSH2_ERROR_TIMEOUT:
break;
default:
printf("Error from ssh2 read %d\n",status);
}
}
else {
alarm(0);
alarm(120);
p+=status;
}
}
If I have a sftp session PRIOR to the exec:
sftp_session = libssh2_sftp_init(session);
sftp_handle =
libssh2_sftp_open(sftp_session, "/tmp/exectest_output",
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,0755);
libssh2_sftp_write(sftp_handle,"Hello\n",6);
libssh2_sftp_close(sftp_handle);
libssh2_sftp_shutdown(sftp_session);
/* exec date */
status = libssh2_channel_exec(channel, "/bin/date");
/* Read output */
p=buf;
signal(SIGALRM,&alarmed);
alarm(120);
alarmclock=0;
while (alarmclock==0) {
status = libssh2_channel_read( channel, p,buf+sizeof(buf)-p);
if (status<=0) {
switch (status) {
case 0:
break;
case LIBSSH2_ERROR_EAGAIN:
break;
case LIBSSH2_ERROR_TIMEOUT:
break;
default:
printf("Error from ssh2 read %d\n",status);
}
}
else {
alarm(0);
alarm(120);
p+=status;
}
}
then the read after the exec returns no data.
Can someone suggest what the problem is?
Have you seen a similar problem?
***************************************************************
This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient, please delete it and notify the sender. Views expressed in this message are those of the individual sender, and are not necessarily the views of the Department of Lands. This email message has been swept by MIMEsweeper for the presence of computer viruses.
***************************************************************
Please consider the environment before printing this email.
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2009-06-09