diff --git a/bin/AST_CRON_audio_3_ftp.pl b/bin/AST_CRON_audio_3_ftp.pl index 9487f280..aa3d9071 100644 --- a/bin/AST_CRON_audio_3_ftp.pl +++ b/bin/AST_CRON_audio_3_ftp.pl @@ -23,12 +23,15 @@ # --GSW = GSM 6.10 codec with RIFF headers (.wav extension) # --GPG = GnuPG encrypted audio files # -# FLAG FOR NO DATE DIRECTORY ON FTP +# FLAG FOR NO DATE DIRECTORY ON FTP (default is to create YYYYMMDD directory) # --NODATEDIR # -# FLAG FOR Y/M/D DATE DIRECTORY ON FTP +# FLAG FOR YYYY/MM/DD DATE DIRECTORIES ON FTP # --YMDdatedir # +# FLAG FOR YYYY/YYYYMMDD DATE DIRECTORIES ON FTP +# --YearYMDdatedir +# # if pinging is not working, try the 'icmp' Ping command in the code instead # # make sure that the following directories exist: @@ -36,7 +39,7 @@ # # This program assumes that recordings are saved by Asterisk as .wav # -# Copyright (C) 2016 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2018 Matt Florell LICENSE: AGPLv2 # # # 80302-1958 - First Build @@ -54,6 +57,7 @@ # 130116-1536 - Added ftp port CLI flag # 150911-2336 - Added GPG encrypted audio file compatibility # 160406-2055 - Added YMDdatedir option +# 180511-2018 - Added --YearYMDdatedir option # ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); @@ -109,6 +113,7 @@ if (length($ARGV[0])>1) print " [--GPG] = copy GPG encrypted files\n"; print " [--nodatedir] = do not put into dated directories\n"; print " [--YMDdatedir] = put into Year/Month/Day dated directories\n"; + print " [--YearYMDdatedir] = put into Year/YYYYMMDD dated directories\n"; print " [--run-check] = concurrency check, die if another instance is running\n"; print " [--max-files=x] = maximum number of files to process, defaults to 100000\n"; print " [--ftp-server=XXX] = FTP server\n"; @@ -148,6 +153,11 @@ if (length($ARGV[0])>1) $YMDdatedir=1; if ($DB) {print "\n----- Y/M/D DATED DIRECTORIES -----\n\n";} } + if ($args =~ /--YearYMDdatedir/i) + { + $YearYMDdatedir=1; + if ($DB) {print "\n----- Year/YYYYMMDD DATED DIRECTORIES -----\n\n";} + } if ($args =~ /--run-check/i) { $run_check=1; @@ -473,7 +483,14 @@ foreach(@FILES) } else { - $ftp->cwd("../"); + if ($YearYMDdatedir > 0) + { + $ftp->cwd("../../"); + } + else + { + $ftp->cwd("../"); + } } } } @@ -497,9 +514,20 @@ foreach(@FILES) } else { - $ftp->mkdir("$start_date"); - $ftp->cwd("$start_date"); - $start_date_PATH = "$start_date/"; + if ($YearYMDdatedir > 0) + { + $ftp->mkdir("$year"); + $ftp->cwd("$year"); + $ftp->mkdir("$start_date"); + $ftp->cwd("$start_date"); + $start_date_PATH = "$year/$start_date/"; + } + else + { + $ftp->mkdir("$start_date"); + $ftp->cwd("$start_date"); + $start_date_PATH = "$start_date/"; + } } } $ftp->binary(); diff --git a/bin/AST_VDsales_export_SFTPSSH2.pl b/bin/AST_VDsales_export_SFTPSSH2.pl index d23dbc36..d55e5e2c 100644 --- a/bin/AST_VDsales_export_SFTPSSH2.pl +++ b/bin/AST_VDsales_export_SFTPSSH2.pl @@ -806,6 +806,19 @@ if ($ftp_transfer > 0) $ssh2->auth_password("$VARREPORT_user","$VARREPORT_pass") or die "Unable to login $@ \n"; $ssh2->scp_put("$PATHweb/vicidial/server_reports/$outfile", "$VARREPORT_dir/$outfile"); $ssh2->disconnect(); + + # use Net::SFTP::Foreign; + # if (!$Q) {print "Sending File Over SFTP: $outfile to $VARREPORT_host \n";} + # my $sftp = Net::SFTP::Foreign->new(host => "$VARREPORT_host", port => "$VARREPORT_port", user => "$VARREPORT_user", password => "$VARREPORT_pass", more => ['-v', qw(-o PreferredAuthentications=password), qw(-o KexAlgorithms=diffie-hellman-group14-sha1)]); + # $sftp->die_on_error("Unable to establish SFTP connection"); + # if ($DB > 0) {print "SFTP connected\n";} + # $sftp->setcwd($VARREPORT_dir) or die "unable to change cwd: " . $sftp->error; + # if ($DB > 0) {print "Changed working directory to $VARREPORT_dir\n";} + # $sftp->put("$PATHweb/vicidial/server_reports/$outfile", "$VARREPORT_dir/$outfile") or die "put failed: " . $sftp->error; + # if ($DBX > 0) {print "putting $PATHweb/vicidial/server_reports/$outfile $VARREPORT_dir/$outfile\n";} + # $sftp->disconnect; + # if ($DB > 0) {print "SFTP disconnected\n";} + } else {