#!/usr/bin/perl -w use Net::SFTP; my $upload_dir = "/var/www/vhosts/domainname/httpsdocs/companyname/tmpfiles"; print "Content-type: text/plain\n\n"; my $filename = "2007-03-27-0088.PDF"; my $sftp = undef; my %args = (user => 'username', password => 'password', debug => 1); eval{$sftp = Net::SFTP->new("domainname", %args);}; if ($@) { print "Error: cannot connect to SFTP server. $@\n"; exit(); } eval{$sftp->put("$upload_dir/$filename", "temp/$filename");}; if ($@) { print "Error: cannot copy file to the SFTP server\n$@\n"; exit(); } print "Complete\n";