in reply to Re^5: sftp->do_write howto?
in thread sftp->do_write howto?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: sftp->do_write howto?
by insaniac (Friar) on Sep 28, 2005 at 11:32 UTC | |
|
Re^7: sftp->do_write howto?
by insaniac (Friar) on Sep 28, 2005 at 11:58 UTC | |
by chrism01 (Friar) on Sep 30, 2005 at 02:08 UTC | |
by insaniac (Friar) on Sep 30, 2005 at 09:04 UTC |