I don't think anything's wrong with your code, what version are you using? Is the pathname on the remotehost correct and do you have permission to write in that directory (very important!!! the first time I thought your $path variable was a local path!) This is the output I always get:use Net::SFTP; use Net::SFTP::Constants qw/:flags/; use strict; use warnings; my $filename = "testfile.dat"; my $payload = "qwertyuiop"; my %args; $args{user} = "insaniac"; $args{password} = "xxxx"; #my $host = "moretrix.com"; my $host = "bear"; my $path = $filename; print "file $path\n"; print "connecting\n"; my $sftp = Net::SFTP->new($host,%args) ; print "open\n"; my $handle = $sftp->do_open($path, SSH2_FXF_WRITE | SSH2_FXF_CREAT); print "write\n"; $sftp->do_write($handle, 0, $payload); print "close\n"; $sftp->do_close($handle);
Maybe try marto 's code above with your login credentials and try uploading a file (to the same $path), see if that works. Otherwise... I have no more ideas :-/connecting open write close
Update: Code is updated to use idsfa's suggestion
to ask a question is a moment of shame
to remain ignorant is a lifelong shame
In reply to Re^5: sftp->do_write howto?
by insaniac
in thread sftp->do_write howto?
by chrism01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |