On Mon, May 2, 2011 at 12:14 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Sun, 1 May 2011, Mark Roden wrote:
>
>> I'm getting an error with trying to copy a file using sftp with
>> libssh2 from a windows 7 machine to a linux machine using libssh2.
>> The error number is 2
>
> which error number?
Sorry, I don't think I was specific enough about the libssh2-ness.
From debugging into the libssh2_sftp_open_ex, I get into sftp_open.
From there, I get to
rc = sftp_packet_requirev(sftp, 2, fopen_responses,
sftp->open_request_id, &data,
&data_len);
(line 946 of sftp.c)
Inside that function is a while statement on line 391 of sftp.c. The
while statement executes once, apparently with no initial return, and
then on the second go-through, the second valid response if statement
is entered on line 393.
Essentially, the server returns an error code, '2'.
Back out into the sftp_open function, that causes the 'badness' flag
to be set to 1 (line 965), presumably because that's not a good
response (the comment indicates that it's a 'status' response, which
is generally bad).
No handle is created as a result.
>
>> and from this thread here:
>
> I failed to see how that was relevant to libssh2. Maybe I'm just dense.
I don't know if it's a libssh2 error or not. I do know that I can
upload files via an sftp client using the same username/password, so I
suspect that I've misconfigured the connection somehow. I also know
that I can get a directory listing (as per the example code), I just
can't seem to be able to write using sftp. I tried using the exact
code from the sftp write example, and that gave the same result. I've
started experimenting with the flags, but I do believe that
something's been incorrectly set up during the establishment of the
connection, and was hoping for some insight there.
>
>> The line that fails is:
>>
>>
>> sftp_handle =
>> libssh2_sftp_open_ex(sftp_session,
>> theSendRemotePath.data(), theSendRemotePath.size(),
>>
>> LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
>>
>> LIBSSH2_SFTP_S_IFREG,LIBSSH2_SFTP_OPENFILE);
>
> And that returns NULL and you then call libssh2_sftp_last_error() which
> returns 2?
I traced the error, as described above. I haven't figured out how to
see fprintf's from Qt's debugging interface in their designer.
Thanks,
Mark
>
> --
>
> / daniel.haxx.se
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
>
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-05-02