[freeside-commits] freeside/FS/FS/Cron upload.pm,1.1,1.2
Ivan,,,
ivan at wavetail.420.am
Fri Apr 22 16:27:51 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/Cron
In directory wavetail.420.am:/tmp/cvs-serv7076
Modified Files:
upload.pm
Log Message:
wtxs upload changes, RT#12326
Index: upload.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Cron/upload.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- upload.pm 12 Aug 2009 14:58:49 -0000 1.1
+++ upload.pm 22 Apr 2011 23:27:49 -0000 1.2
@@ -13,6 +13,7 @@
use HTTP::Request;
use HTTP::Request::Common;
use HTTP::Response;
+use Net::FTP;
@ISA = qw( Exporter );
@EXPORT_OK = qw ( upload );
@@ -153,6 +154,8 @@
unlink "agentnum$agentnum-$opt{date}-header.csv",
"agentnum$agentnum-$opt{date}-detail.csv";
+ if ( $url =~ /^http/i ) {
+
my $ua = new LWP::UserAgent;
my $res = $ua->request( POST( $url,
'Content_Type' => 'form-data',
@@ -168,6 +171,28 @@
die "upload failed: ". $res->status_line. "\n"
unless $res->is_success;
+ } elsif ( $url =~ /^ftp:\/\/([\w\.]+)(\/.*)$/i ) {
+
+ my($hostname, $path) = ($1, $2);
+
+ my $ftp = new Net::FTP($hostname)
+ or die "can't connect to $hostname: $@\n";
+ $ftp->login($username, $password)
+ or die "can't login to $hostname: ". $ftp->message."\n";
+ $ftp->cwd($path)
+ or die "can't cd $path on $hostname: ". $ftp->message. "\n";
+ $ftp->binary
+ or die "can't set binary mode on $hostname\n";
+
+ $ftp->put($zipfile)
+ or die "can't put $zipfile: ". $ftp->message. "\n";
+
+ $ftp->quit;
+
+ } else {
+ die "unknown scheme in URL $url\n";
+ }
+
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';
More information about the freeside-commits
mailing list