#sftp_script.pl#!/usr/bin/perl use strict; use warnings; open(LOG, '>', 'LOG_FILE') or die "Can't open stdout: $!"; open(CMD, 'perl sftp_script.pl'); open(STDERR, '>&', STDOUT) or die "Can't redirect stderr: $!"; open(STDERR, '>', 'LOG_FILE') or die "Can't redirect stderr: $!"; print "LOG_FILE\n"; while (<CMD>) { print_stuff ($_); } sub print_stuff { my ($line) = @_; print LOG $line; print $line; } close(CMD) or die "close CMD failed: $!"; exit 0;
It's a one-step process for installing Net::SFTP. Just do cpan Net::SFTP#!perl use strict; use warnings; use Net::SFTP; my $host = 'localhost'; my $user = 'user'; my $password = 'password'; my %args = ( user => $user, password => $password, port => 22, debug => 1, ); my $local = '/path/to/some/file'; my $remote = '/path/to/remote_dir/file'; my $sftp = Net::SFTP->new($host, %args); die "Can't put file: $!\n" unless $sftp->put($local, $remote); close $local;
Update: To install Net::SSH::Perl, do it manually as:
perl Makefile.PL machine=none make install
In reply to Re: Having trouble getting sftp to work
by Khen1950fx
in thread Having trouble getting sftp to work
by dirtdog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |