and the response was...#!/usr/bin/perl use Net::SFTP; use Net::SFTP::Constants qw/:flags/; use strict; use warnings; my ( $filename, $payload, $host, $sftp, %args, $path, $handle, $err_code, $err_mesg ); $filename = "testfile.dat"; $payload = "qwertyuiop"; %args = (user => "yyyyyyyyyy", password => "xxxxxx"); $host = "a.b.c.d"; $path = "/network/www/ticketattach/".$filename; print "connecting\n"; eval { $sftp = Net::SFTP->new($host, %args) }; ($err_code, $err_mesg) = $sftp->status; if($err_code) { print "Err_code:$err_code | err_mesg:$err_mesg\n"; exit $err_code }; print "open\n"; $handle = $sftp->do_open($path, SSH2_FXF_WRITE | SSH2_FXF_CREAT); #$handle = $sftp->do_open($path, 0x02| 0x08); ($err_code, $err_mesg) = $sftp->status; if($err_code) { print "Err_code:$err_code | err_mesg:$err_mesg\n"; exit $err_code }; print "write\n"; $sftp->do_write($handle, 0, $payload); ($err_code, $err_mesg) = $sftp->status; if($err_code) { print "Err_code:$err_code | err_mesg:$err_mesg\n"; exit $err_code }; print "close\n"; $sftp->do_close($handle); ($err_code, $err_mesg) = $sftp->status; if($err_code) { print "Err_code:$err_code | err_mesg:$err_mesg\n"; exit $err_code };
and as mentioned before I can ssh/sftp fine from the cmd line, but running this script from the same env manually does the above .. grrr... ie won't connect, forget about uploading.connecting Can't call method "status" on an undefined value at ./sftp.pl line 28.
In reply to Re^6: sftp->do_write howto?
by chrism01
in thread sftp->do_write howto?
by chrism01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |