#!/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 () { print_stuff ($_); } sub print_stuff { my ($line) = @_; print LOG $line; print $line; } close(CMD) or die "close CMD failed: $!"; exit 0; #### #!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; #### perl Makefile.PL machine=none make install