[freeside-commits] freeside/FS/bin freeside-cdr-sftp_and_import, 1.5, 1.6 freeside-queued, 1.47, 1.48
Mark Wells
mark at wavetail.420.am
Tue Jul 6 13:56:43 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail.420.am:/tmp/cvs-serv22217
Modified Files:
freeside-cdr-sftp_and_import freeside-queued
Log Message:
add command line opts for port, passive mode, and debug level, RT#9115
Index: freeside-cdr-sftp_and_import
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-cdr-sftp_and_import,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -d -r1.5 -r1.6
--- freeside-cdr-sftp_and_import 19 Nov 2009 09:47:02 -0000 1.5
+++ freeside-cdr-sftp_and_import 6 Jul 2010 20:56:41 -0000 1.6
@@ -11,8 +11,8 @@
# parse command line
###
-use vars qw( $opt_m $opt_p $opt_r $opt_e $opt_d $opt_v );
-getopts('m:p:r:e:d:v');
+use vars qw( $opt_m $opt_p $opt_r $opt_e $opt_d $opt_v $opt_P $opt_a );
+getopts('m:p:r:e:d:v:P:a');
$opt_e ||= 'csv';
#$opt_e = ".$opt_e" unless $opt_e =~ /^\./;
@@ -20,11 +20,13 @@
$opt_p ||= '';
+my %options = ();
+
my $user = shift or die &usage;
adminsuidsetup $user;
# %%%FREESIDE_CACHE%%%
-my $cachedir = '/usr/local/etc/freeside/cache.'. datasrc. '/cdrs';
+my $cachedir = '%%%FREESIDE_CACHE%%%/cache.'. datasrc. '/cdrs';
mkdir $cachedir unless -d $cachedir;
my $format = shift or die &usage;
@@ -44,11 +46,18 @@
my $ls;
if($opt_m eq 'ftp') {
+ $options{'Port'} = $opt_P if $opt_P;
+ $options{'Debug'} = $opt_v if $opt_v;
+ $options{'Passive'} = $opt_a if $opt_a;
+
my $ls_ftp = ftp();
$ls = [ grep { /^$opt_p.*\.$opt_e$/i } $ls_ftp->ls ];
}
elsif($opt_m eq 'sftp') {
+ $options{'port'} = $opt_P if $opt_P;
+ $options{'debug'} = $opt_v if $opt_v;
+
my $ls_sftp = sftp();
$ls_sftp->setcwd($opt_r) or die "can't chdir to $opt_r\n"
@@ -124,7 +133,8 @@
my ($hostname, $user) = reverse split('@', $servername);
my ($user, $pass) = split(':', $user);
- my $ftp = Net::FTP->new($hostname) or die "FTP connection to '$hostname' failed.";
+ my $ftp = Net::FTP->new($hostname, %options)
+ or die "FTP connection to '$hostname' failed.";
$ftp->login($user, $pass) or die "FTP login failed: ".$ftp->message;
$ftp->cwd($opt_r) or die "can't chdir to $opt_r\n" if $opt_r;
return $ftp;
@@ -149,12 +159,14 @@
=head1 SYNOPSIS
- cdr.sftp_and_import [ -m method ][ -p prefix ] [ -e extension ] [ -r remotefolder ] [ -d donefolder ] [ -v ] user format [sftpuser@]servername
+ cdr.sftp_and_import [ -m method ] [ -p prefix ] [ -e extension ]
+ [ -r remotefolder ] [ -d donefolder ] [ -v level ] [ -P port ]
+ [ -a ] user format [sftpuser@]servername
=head1 DESCRIPTION
-Command line tool to download CDR files from a remote server via SFTP or FTP and then
-import them into the database.
+Command line tool to download CDR files from a remote server via SFTP
+or FTP and then import them into the database.
-m: transfer method (sftp or ftp), defaults to sftp
@@ -166,7 +178,12 @@
-d: if specified, moves files to the specified folder when done
--v: verbose
+-P: if specified, sets the port to use
+
+-a: use ftp passive mode
+
+-v: set verbosity level; this script only has one level, but it will
+ be passed as the 'debug' argument to the transport method
user: freeside username
Index: freeside-queued
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-queued,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -w -d -r1.47 -r1.48
--- freeside-queued 13 May 2010 05:43:22 -0000 1.47
+++ freeside-queued 6 Jul 2010 20:56:41 -0000 1.48
@@ -5,6 +5,8 @@
use POSIX qw(:sys_wait_h);
use IO::File;
use Getopt::Std;
+use MIME::Base64 qw(decode_base64);
+use Storable qw(thaw);
use FS::UID qw(adminsuidsetup forksuidsetup driver_name dbh myconnect);
use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm);
use FS::Conf;
More information about the freeside-commits
mailing list