CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
SFTP ftp->put

 



perl_issue
New User

Jul 1, 2011, 2:37 AM

Post #1 of 5 (1005 views)
SFTP ftp->put Can't Post

Am trying to ftping the file to remote machine, and am getting time stamp on that file is same as the local machine. Is there any that i can get current time and date on the fte'd file?


rovf
Veteran

Jul 1, 2011, 2:42 AM

Post #2 of 5 (1003 views)
Re: [perl_issue] SFTP ftp->put [In reply to] Can't Post

I guess you are using Net::SFTP. Have a look at the member functions lstat and stat. I have not tried them on my own, but according to the documentation, they should do what you want.


perl_issue
New User

Jul 1, 2011, 6:45 AM

Post #3 of 5 (976 views)
Re: [rovf] SFTP ftp->put [In reply to] Can't Post

Am using to sftp->do_setstat function to get the system time as timestamp of the ftp'ed file. But it is not working fine for me. Let me know if there any suggestions.





my %args = (ssh_args => { identity_files => [ "$ENV{HOME}/.ssh/id_rsa"]} );
my $VAR1 = bless( {
'mtime' => 1203350526,
}, 'Net::SFTP::Attributes' );

my $attrs = Net::SFTP::Attributes->new(Stat => [ stat "$file" ]);


$ftp = Net::SFTP->new($machine, %args);
$ftp->put($file,$file);


$ftp->do_setstat($file, $attrs);


rovf
Veteran

Jul 1, 2011, 8:04 AM

Post #4 of 5 (969 views)
Re: [perl_issue] SFTP ftp->put [In reply to] Can't Post

As I said in my posting, the function to do this is stat or lstat, not do_setstat.


salva
Novice

Jul 2, 2011, 10:48 AM

Post #5 of 5 (956 views)
Re: [perl_issue] SFTP ftp->put [In reply to] Can't Post

use Net::SFTP::Foreign ( http://search.cpan.org/perldoc?Net::SFTP::Foreign):


Code
use Net::SFTP::Foreign; 

my $sftp = Net::SFTP::Foreign->new(...);
$sftp->put("/local/file/path", "/remote/path", copy_time => 0);


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives