curl-users
Re: attempted scp responds with Info: Channel failed to close: -34
Date: Fri, 25 Apr 2014 18:15:12 -0400 (EDT)
On April 25, 2014 at 5:43 PM Dan Fandrich <dan_at_coneharvesters.com>
wrote:
> On Fri, Apr 25, 2014 at 05:10:31PM -0400, dev wrote:
> > Not too sure why I am getting this message.
> >
> > Info: Channel failed to close: -34
> >
> > Trying to test an scp upload of a test file.
>
> libssh2 error -34 is LIBSSH2_ERROR_INVAL, which seems pretty generic.
> But, it's possible it's related to the issue below.
Yep .. I was thinking the same but thanks to you I see my error.
In truth I didn't want to upload a file at all but in fact I
was trying to write a file on a remote server, via SSH and the
source of the data is a memory buffer pointed at bu some *foo
pointer. I was supposed to use CURLOPT_READFUNCTION but figured
I would cut a corner and just read a file into a vuffer and then
transfer the data. But no .. to cut corners a bit I went back
to just transfering the file and borked up the file position.
Fridays .. they do that. :-\
> > inputdat = fopen( DATFILENAME, "r" );
> >
> > fread ( dat_buffer, datfid.st_size, 1, inputdat );
>
> This sets the input stream to the end of the file...
Yep. Good eye there Dan.
I think perhaps I should just get on with the task of doing the
file write from a buffer directly and bypass the while file read
process entirely.
> > /* supply the file here */
> > curl_easy_setopt ( curl,
> > CURLOPT_READDATA, inputdat );
>
> ...so when it's read by libcurl, there's nothing left to read. Hence,
> a 0-byte
> file on the other side. Adding a rewind(inputdat) should fix this, as
> would
> sending the data already read from that buffer instead of reading from
> the
> file again.
nicely caught.
Still leaves me wondering about the hanging channel .. probably because
I was supposed to send some data specified in length by
CURLOPT_INFILESIZE
and then sent nothing. That could be the issue.
> >
> > /* using SCP CURLOPT_INFILESIZE is needed */
> > /* note that CURLOPT_INFILESIZE_LARGE requires type
> > curl_off_t
> > */
> > curl_easy_setopt ( curl, CURLOPT_INFILESIZE,
> > (long) datfid.st_size );
Really I was supposed to use the length of my buffer here. Zero
terminated.
> > ps: yes .. even though I provide the passphrase I had to resort to
> > username and password to auth. That's a separate mystery.
>
> The username is needed so the remote side knows who's trying to log
> in. If
> you're using a public key as authenticator, you can leave the password
> empty.
Ah. Makes sense.
So in other news my daily builds are being submitted and I only have
one test failure. I can talk on that on another thread perhaps.
Thank you Dan, you are very helpful.
Dennis
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-04-26