[freeside-commits] freeside/FS/bin freeside-cdr-sftp_and_import, 1.4.2.1, 1.4.2.2
Mark Wells
mark at wavetail.420.am
Tue Jul 6 14:01:36 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail.420.am:/tmp/cvs-serv22682
Modified Files:
Tag: FREESIDE_1_9_BRANCH
freeside-cdr-sftp_and_import
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.4.2.1
retrieving revision 1.4.2.2
diff -u -w -d -r1.4.2.1 -r1.4.2.2
--- freeside-cdr-sftp_and_import 19 Nov 2009 09:47:15 -0000 1.4.2.1
+++ freeside-cdr-sftp_and_import 6 Jul 2010 21:01:34 -0000 1.4.2.2
@@ -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
More information about the freeside-commits
mailing list