From 9b7c40bd29f205c3ed8f7eadb3f964d7ee4802a3 Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 24 Mar 2008 20:01:20 +0000 Subject: [PATCH] move old audio recording mixing scripts from bin to extras/old_bin git-svn-id: svn://192.168.202.10@810 3d104415-ff17-0410-8863-d5cf3c621b8a --- bin/AST_CRON_mix_recordings.pl | 183 ---------------- bin/AST_CRON_mix_recordings_BASIC.pl | 148 ------------- bin/AST_CRON_mix_recordings_GSM.pl | 204 ------------------ bin/AST_CRON_mix_recordings_MP3.pl | 206 ------------------ bin/AST_CRON_mix_recordings_MP3_DATE.pl | 231 --------------------- bin/AST_CRON_mix_recordings_VDonly_DATE.pl | 198 ------------------ 6 files changed, 1170 deletions(-) delete mode 100644 bin/AST_CRON_mix_recordings.pl delete mode 100644 bin/AST_CRON_mix_recordings_BASIC.pl delete mode 100644 bin/AST_CRON_mix_recordings_GSM.pl delete mode 100644 bin/AST_CRON_mix_recordings_MP3.pl delete mode 100644 bin/AST_CRON_mix_recordings_MP3_DATE.pl delete mode 100644 bin/AST_CRON_mix_recordings_VDonly_DATE.pl diff --git a/bin/AST_CRON_mix_recordings.pl b/bin/AST_CRON_mix_recordings.pl deleted file mode 100644 index 39e98e24..00000000 --- a/bin/AST_CRON_mix_recordings.pl +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/perl -# -# AST_CRON_mix_recordings.pl -# runs every 5 minutes and mixes the call recordings in the monitor together -# and puts the resulting ALL file into the DONE directory in the "monitor" dir -# -# soxmix is REQUIRED to use this script, soxmix is available only as part of -# the sox audio package, and only in newer versions. Make sure you have soxmix -# installed properly and in your path -# -# put an entry into the cron of of your asterisk machine to run this script -# every 5 minutes or however often you desire -# -# make sure that the following directories exist: -# /var/spool/asterisk/monitor # default Asterisk recording directory -# /var/spool/asterisk/monitor/DONE # where the combined files are put -# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put -# -# This program assumes that recordings are saved as .wav -# should be easy to change this code if you use .gsm instead -# -# This program also sends the ALL combined file to an FTP server for archival -# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the -# file transfer section of the code to deactivate remote copying of the -# recording files -# -# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 -# -# -# 51021-1058 - Added quotes around CLI executed commands -# 51122-1458 - Added soxmix binary path check -# 60318-0921 - Added ability to mix gsm audio files -# 60807-1308 - Modified to use /etc/astguiclient.conf for settings -# 71004-1124 - Changed to not move ORIG recordings if FTP server does not Ping -# 71005-0049 - Altered script to use astguiclient.conf for settings -# - - -#$v=1; - -# Default variables for FTP -$VARFTP_host = '10.0.0.4'; -$VARFTP_user = 'cron'; -$VARFTP_pass = 'test'; -$VARFTP_dir = 'RECORDINGS'; - - -# default path to astguiclient configuration file: -$PATHconf = '/etc/astguiclient.conf'; - -open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; -@conf = ; -close(conf); -$i=0; -foreach(@conf) - { - $line = $conf[$i]; - $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; - if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) - {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} - if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) - {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} - if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) - {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} - if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) - {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} - if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) - {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} - if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) - {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} - if ( ($line =~ /PATHDONEmonitor/) && ($CLIDONEmonitor < 1) ) - {$PATHDONEmonitor = $line; $PATHDONEmonitor =~ s/.*=//gi;} - if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) - {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) - {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) - {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) - {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) - {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) - {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) ) - {$VARFTP_host = $line; $VARFTP_host =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) ) - {$VARFTP_user = $line; $VARFTP_user =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) ) - {$VARFTP_pass = $line; $VARFTP_pass =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) ) - {$VARFTP_port = $line; $VARFTP_port =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) ) - {$VARFTP_dir = $line; $VARFTP_dir =~ s/.*=//gi;} - if ( ($line =~ /^VARHTTP_path/) && ($CLIHTTP_path < 1) ) - {$VARHTTP_path = $line; $VARHTTP_path =~ s/.*=//gi;} - $i++; - } - -# Customized Variables -$server_ip = $VARserver_ip; # Asterisk server IP - -### directory where in/out recordings are saved to by Asterisk -$dir1 = "$PATHmonitor"; -$dir2 = "$PATHDONEmonitor"; - -$soxmixbin = ''; -if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';} -else - { - if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';} - else - { - print "Can't find soxmix binary! Exiting...\n"; - exit; - } - } - -use Net::Ping; -use Net::FTP; - - - opendir(FILE, "$dir1/"); - @FILES = readdir(FILE); - -$i=0; -foreach(@FILES) - { - $size1 = 0; - $size2 = 0; - - if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) ) - { - - $size1 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size1\n";} - sleep(1); - $size2 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size2\n\n";} - - if ( ($FILES[$i] !~ /out\.wav|out\.gsm/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4)) - { - $INfile = $FILES[$i]; - $OUTfile = $FILES[$i]; - $OUTfile =~ s/-in\.wav/-out.wav/gi; - $OUTfile =~ s/-in\.gsm/-out.gsm/gi; - $ALLfile = $FILES[$i]; - $ALLfile =~ s/-in\.wav/-all.wav/gi; - $ALLfile =~ s/-in\.gsm/-all.gsm/gi; - - if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} - - ### BEGIN Remote file transfer - $p = Net::Ping->new(); - $ping_good = $p->ping("$VARFTP_host"); - - if ($ping_good) - { - `$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir2/$ALLfile"`; - if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} - if (!$T) - { - `mv -f "$dir1/$INfile" "$dir2/ORIG/$INfile"`; - `mv -f "$dir1/$OUTfile" "$dir2/ORIG/$OUTfile"`; - } - - $ftp = Net::FTP->new("$VARFTP_host", Port => 21); - $ftp->login("$VARFTP_user","$VARFTP_pass"); - $ftp->cwd("$VARFTP_dir"); - $ftp->binary(); - $ftp->put("$dir2/$ALLfile", "$ALLfile"); - $ftp->quit; - } - ### END Remote file transfer - - } - } - $i++; - } - -if ($v) {print "DONE... EXITING\n\n";} - -exit; diff --git a/bin/AST_CRON_mix_recordings_BASIC.pl b/bin/AST_CRON_mix_recordings_BASIC.pl deleted file mode 100644 index 04c67b00..00000000 --- a/bin/AST_CRON_mix_recordings_BASIC.pl +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/perl -# -# AST_CRON_mix_recordings_BASIC.pl -# runs every 5 minutes and mixes the call recordings in the monitor together -# and puts the resulting ALL file into the DONE directory in the "monitor" dir -# -# soxmix is REQUIRED to use this script, soxmix is available only as part of -# the sox audio package, and only in newer versions. Make sure you have soxmix -# installed properly and in your path -# -# put an entry into the cron of of your asterisk machine to run this script -# every 5 minutes or however often you desire -# -# make sure that the following directories exist: -# /var/spool/asterisk/monitor # default Asterisk recording directory -# /var/spool/asterisk/monitor/DONE # where the combined files are put -# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put -# -# This program assumes that recordings are saved as .wav -# should be easy to change this code if you use .gsm instead -# -# This program also sends the ALL combined file to an FTP server for archival -# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the -# file transfer section of the code to deactivate remote copying of the -# recording files -# -# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 -# -# -# 51021-1058 - Added quotes around CLI executed commands -# 51122-1456 - Added soxmix binary path check -# 60318-0921 - Added ability to mix gsm audio files -# 60807-1308 - Modified to use /etc/astguiclient.conf for settings -# - - -# default path to astguiclient configuration file: -$PATHconf = '/etc/astguiclient.conf'; - -open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; -@conf = ; -close(conf); -$i=0; -foreach(@conf) - { - $line = $conf[$i]; - $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; - if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) - {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} - if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) - {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} - if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) - {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} - if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) - {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} - if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) - {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} - if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) - {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} - if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) - {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) - {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) - {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) - {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) - {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) - {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} - $i++; - } - -# Customized Variables -$server_ip = $VARserver_ip; # Asterisk server IP - -### directory where in/out recordings are saved to by Asterisk -$dir1 = "$PATHmonitor"; - -$soxmixbin = ''; -if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';} -else - { - if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';} - else - { - print "Can't find soxmix binary! Trying sox...\n"; - if ( -e ('/usr/bin/sox')) {$soxmixbin = '/usr/bin/sox -m';} - else - { - if ( -e ('/usr/local/bin/sox')) {$soxmixbin = '/usr/local/bin/sox -m';} - else - { - print "Can't find sox binary! Exiting...\n"; - exit; - } - } - } - } - - opendir(FILE, "$dir1/"); - @FILES = readdir(FILE); - -$i=0; -foreach(@FILES) - { - $size1 = 0; - $size2 = 0; - - if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) ) - { - - $size1 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size1\n";} - sleep(1); - $size2 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size2\n\n";} - - - if ( ($FILES[$i] !~ /out\.wav|out\.gsm/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4)) - { - $INfile = $FILES[$i]; - $OUTfile = $FILES[$i]; - $OUTfile =~ s/-in\.wav/-out.wav/gi; - $OUTfile =~ s/-in\.gsm/-out.gsm/gi; - $ALLfile = $FILES[$i]; - $ALLfile =~ s/-in\.wav/-all.wav/gi; - $ALLfile =~ s/-in\.gsm/-all.gsm/gi; - - if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} - - `$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir1/$ALLfile"`; - if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} - if (!$T) - { - `mv -f "$dir1/$INfile" "$dir1/ORIG/$INfile"`; - `mv -f "$dir1/$OUTfile" "$dir1/ORIG/$OUTfile"`; - `mv -f "$dir1/$ALLfile" "$dir1/DONE/$ALLfile"`; - } - } - } - $i++; - } - -if ($v) {print "DONE... EXITING\n\n";} - -exit; diff --git a/bin/AST_CRON_mix_recordings_GSM.pl b/bin/AST_CRON_mix_recordings_GSM.pl deleted file mode 100644 index 56e2fe7b..00000000 --- a/bin/AST_CRON_mix_recordings_GSM.pl +++ /dev/null @@ -1,204 +0,0 @@ -#!/usr/bin/perl -# -# AST_CRON_mix_recordings_GSM.pl -# runs every 5 minutes and mixes the call recordings in the monitor together -# and puts the resulting ALL file into the DONE directory in the "monitor" dir -# and converts the ALL file to GSM format to save space. -# -# soxmix is REQUIRED to use this script, soxmix is available only as part of -# the sox audio package, and only in newer versions. Make sure you have soxmix -# installed properly and in your path -# -# put an entry into the cron of of your asterisk machine to run this script -# every 5 minutes or however often you desire -# -# make sure that the following directories exist: -# /var/spool/asterisk/monitor # default Asterisk recording directory -# /var/spool/asterisk/monitor/DONE # where the combined files are put -# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put -# -# This program assumes that recordings are saved as .wav -# should be easy to change this code if you use .gsm instead -# -# This program also sends the ALL combined file to an FTP server for archival -# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the -# file transfer section of the code to deactivate remote copying of the -# recording files -# -# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 -# -# -# 51021-1058 - Added quotes around CLI executed commands -# 51122-1455 - Added soxmix and sox binary path check -# 60807-1308 - Modified to use /etc/astguiclient.conf for settings -# 71004-1124 - Changed to not move ORIG recordings if FTP server does not Ping -# 71005-0049 - Altered script to use astguiclient.conf for settings -# - - -# Default variables for FTP -$VARFTP_host = '10.0.0.4'; -$VARFTP_user = 'cron'; -$VARFTP_pass = 'test'; -$VARFTP_dir = 'RECORDINGS'; -$VARFTP_port = '21'; - - -# default path to astguiclient configuration file: -$PATHconf = '/etc/astguiclient.conf'; - -open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; -@conf = ; -close(conf); -$i=0; -foreach(@conf) - { - $line = $conf[$i]; - $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; - if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) - {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} - if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) - {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} - if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) - {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} - if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) - {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} - if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) - {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} - if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) - {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} - if ( ($line =~ /PATHDONEmonitor/) && ($CLIDONEmonitor < 1) ) - {$PATHDONEmonitor = $line; $PATHDONEmonitor =~ s/.*=//gi;} - if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) - {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) - {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) - {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) - {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) - {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) - {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) ) - {$VARFTP_host = $line; $VARFTP_host =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) ) - {$VARFTP_user = $line; $VARFTP_user =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) ) - {$VARFTP_pass = $line; $VARFTP_pass =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) ) - {$VARFTP_port = $line; $VARFTP_port =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) ) - {$VARFTP_dir = $line; $VARFTP_dir =~ s/.*=//gi;} - if ( ($line =~ /^VARHTTP_path/) && ($CLIHTTP_path < 1) ) - {$VARHTTP_path = $line; $VARHTTP_path =~ s/.*=//gi;} - $i++; - } - -# Customized Variables -$server_ip = $VARserver_ip; # Asterisk server IP - -### directory where in/out recordings are saved to by Asterisk -$dir1 = "$PATHmonitor"; -$dir2 = "$PATHDONEmonitor"; - -$soxmixbin = ''; -if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';} -else - { - if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';} - else - { - print "Can't find soxmix binary! Exiting...\n"; - exit; - } - } -$soxbin = ''; -if ( -e ('/usr/bin/sox')) {$soxbin = '/usr/bin/sox';} -else - { - if ( -e ('/usr/local/bin/sox')) {$soxbin = '/usr/local/bin/sox';} - else - { - print "Can't find sox binary! Exiting...\n"; - exit; - } - } - -use Net::Ping; -use Net::FTP; - - - opendir(FILE, "$dir1/"); - @FILES = readdir(FILE); - -$i=0; -foreach(@FILES) - { - $size1 = 0; - $size2 = 0; - - if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) ) - { - - $size1 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size1\n";} - sleep(1); - $size2 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size2\n\n";} - - - if ( ($FILES[$i] !~ /out\.wav/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4)) - { - $INfile = $FILES[$i]; - $OUTfile = $FILES[$i]; - $OUTfile =~ s/-in\.wav/-out.wav/gi; - $ALLfile = $FILES[$i]; - $ALLfile =~ s/-in\.wav/-all.wav/gi; - $GSMfile = $ALLfile; - $GSMfile =~ s/-all\.wav/-all.gsm/gi; - - if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} - - ### BEGIN Remote file transfer - $p = Net::Ping->new(); - $ping_good = $p->ping("$VARFTP_host"); - - if ($ping_good) - { - `$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir2/$ALLfile"`; - if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} - if (!$T) - { - `mv -f "$dir1/$INfile" "$dir2/ORIG/$INfile"`; - `mv -f "$dir1/$OUTfile" "$dir2/ORIG/$OUTfile"`; - } - - `$soxbin "$dir2/$ALLfile" "$dir2/$GSMfile"`; - - if (!$T) - { - `rm -f "$dir2/$ALLfile"`; - } - - if($DB){print STDERR "\n|/usr/bin/sox $live_folder/$filename[$k]$WAV $arch_folder/$filename[$k]$GSM|\n";} - chmod 0755, "$dir2/$GSMfile"; - - $ftp = Net::FTP->new("$VARFTP_host", Port => $VARFTP_port, Debug => 0, Passive => 1); - $ftp->login("$VARFTP_user","$VARFTP_pass"); - $ftp->cwd("$VARFTP_dir"); - $ftp->binary(); - $ftp->put("$dir2/$GSMfile", "$GSMfile"); - $ftp->quit; - } - ### END Remote file transfer - - } - } - $i++; - } - -if ($v) {print "DONE... EXITING\n\n";} - -exit; diff --git a/bin/AST_CRON_mix_recordings_MP3.pl b/bin/AST_CRON_mix_recordings_MP3.pl deleted file mode 100644 index c548a14a..00000000 --- a/bin/AST_CRON_mix_recordings_MP3.pl +++ /dev/null @@ -1,206 +0,0 @@ -#!/usr/bin/perl -# -# AST_CRON_mix_recordings_MP3.pl -# runs every 5 minutes and mixes the call recordings in the monitor together -# and puts the resulting ALL file into the DONE directory in the "monitor" dir -# and converts the ALL file to GSM format to save space. -# -# soxmix is REQUIRED to use this script, soxmix is available only as part of -# the sox audio package, and only in newer versions. Make sure you have soxmix -# installed properly and in your path -# -# put an entry into the cron of of your asterisk machine to run this script -# every 5 minutes or however often you desire -# -# make sure that the following directories exist: -# /var/spool/asterisk/monitor # default Asterisk recording directory -# /var/spool/asterisk/monitor/DONE # where the combined files are put -# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put -# -# This program assumes that recordings are saved as .wav -# should be easy to change this code if you use .gsm instead -# -# This program also sends the ALL combined file to an FTP server for archival -# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the -# file transfer section of the code to deactivate remote copying of the -# recording files -# -# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 -# Contributions by Mike Lord -# -# 51021-1058 - Added quotes around CLI executed commands -# 51122-1455 - Added soxmix and sox binary path check -# 60616-1027 - Modified to convert to MP3 format -# 60807-1308 - Modified to use /etc/astguiclient.conf for settings -# 71004-1124 - Changed to not move ORIG recordings if FTP server does not Ping -# 71005-0049 - Altered script to use astguiclient.conf for settings -# - - -# Default variables for FTP -$VARFTP_host = '10.0.0.4'; -$VARFTP_user = 'cron'; -$VARFTP_pass = 'test'; -$VARFTP_dir = 'recordings'; -$VARFTP_port = '21'; - - -# default path to astguiclient configuration file: -$PATHconf = '/etc/astguiclient.conf'; - -open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; -@conf = ; -close(conf); -$i=0; -foreach(@conf) - { - $line = $conf[$i]; - $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; - if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) - {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} - if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) - {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} - if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) - {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} - if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) - {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} - if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) - {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} - if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) - {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} - if ( ($line =~ /PATHDONEmonitor/) && ($CLIDONEmonitor < 1) ) - {$PATHDONEmonitor = $line; $PATHDONEmonitor =~ s/.*=//gi;} - if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) - {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) - {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) - {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) - {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) - {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) - {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) ) - {$VARFTP_host = $line; $VARFTP_host =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) ) - {$VARFTP_user = $line; $VARFTP_user =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) ) - {$VARFTP_pass = $line; $VARFTP_pass =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) ) - {$VARFTP_port = $line; $VARFTP_port =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) ) - {$VARFTP_dir = $line; $VARFTP_dir =~ s/.*=//gi;} - if ( ($line =~ /^VARHTTP_path/) && ($CLIHTTP_path < 1) ) - {$VARHTTP_path = $line; $VARHTTP_path =~ s/.*=//gi;} - $i++; - } - -# Customized Variables -$server_ip = $VARserver_ip; # Asterisk server IP - -### directory where in/out recordings are saved to by Asterisk -$dir1 = "$PATHmonitor"; -$dir2 = "$PATHDONEmonitor"; - -$soxmixbin = ''; -if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';} -else - { - if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';} - else - { - print "Can't find soxmix binary! Exiting...\n"; - exit; - } - } -$lamebin = ''; -if ( -e ('/usr/bin/lame')) {$lamebin = '/usr/bin/lame';} -else - { - if ( -e ('/usr/local/bin/lame')) {$lamebin = '/usr/local/bin/lame';} - else - { - print "Can't find lame binary! Exiting...\n"; - exit; - } - } - -use Net::Ping; -use Net::FTP; - - - opendir(FILE, "$dir1/"); - @FILES = readdir(FILE); - -$i=0; -foreach(@FILES) - { - $size1 = 0; - $size2 = 0; - - if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) ) - { - - $size1 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size1\n";} - sleep(1); - $size2 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size2\n\n";} - - - if ( ($FILES[$i] !~ /out\.wav/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4)) - { - $INfile = $FILES[$i]; - $OUTfile = $FILES[$i]; - $OUTfile =~ s/-in\.wav/-out.wav/gi; - $ALLfile = $FILES[$i]; - $ALLfile =~ s/-in\.wav/-all.wav/gi; - $MP3file = $ALLfile; - $MP3file =~ s/-all\.wav/-all.mp3/gi; - - if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} - - ### BEGIN Remote file transfer - $p = Net::Ping->new(); - $ping_good = $p->ping("$VARFTP_host"); - - if ($ping_good) - { - `$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir2/$ALLfile"`; - if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} - - `$lamebin -b 16 -m m --silent "$dir2/$ALLfile" "$dir2/$MP3file"`; - - if($DB){print STDERR "\n|/usr/bin/sox $live_folder/$filename[$k]$WAV $arch_folder/$filename[$k]$GSM|\n";} - chmod 0755, "$dir2/$MP3file"; - - $ftp = Net::FTP->new("$VARFTP_host", Port => $VARFTP_port, Debug => 0, Passive => 1); - $ftp->login("$VARFTP_user","$VARFTP_pass"); - $ftp->cwd("$VARFTP_dir"); - $ftp->binary(); - $ftp->put("$dir2/$MP3file", "$MP3file"); - $ftp->quit; - - if (!$T) - { - `mv -f "$dir1/$INfile" "$dir2/ORIG/$INfile"`; - `mv -f "$dir1/$OUTfile" "$dir2/ORIG/$OUTfile"`; - } - if (!$T) - { - `rm -f "$dir2/$ALLfile"`; - } - - } - ### END Remote file transfer - - } - } - $i++; - } - -if ($v) {print "DONE... EXITING\n\n";} - -exit; diff --git a/bin/AST_CRON_mix_recordings_MP3_DATE.pl b/bin/AST_CRON_mix_recordings_MP3_DATE.pl deleted file mode 100644 index e3a9cf01..00000000 --- a/bin/AST_CRON_mix_recordings_MP3_DATE.pl +++ /dev/null @@ -1,231 +0,0 @@ -#!/usr/bin/perl -# -# AST_CRON_mix_recordings_MP3_DATE.pl -# runs every 5 minutes and mixes the call recordings in the monitor together -# and puts the resulting ALL file into the DONE directory in the "monitor" dir -# and converts the ALL file to GSM format to save space. -# -# soxmix is REQUIRED to use this script, soxmix is available only as part of -# the sox audio package, and only in newer versions. Make sure you have soxmix -# installed properly and in your path -# -# put an entry into the cron of of your asterisk machine to run this script -# every 5 minutes or however often you desire -# -# make sure that the following directories exist: -# /var/spool/asterisk/monitor # default Asterisk recording directory -# /var/spool/asterisk/monitor/DONE # where the combined files are put -# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put -# -# This program assumes that recordings are saved as .wav -# should be easy to change this code if you use .gsm instead -# -# This program also sends the ALL combined file to an FTP server for archival -# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the -# file transfer section of the code to deactivate remote copying of the -# recording files -# -# MODIFIED BY MAGMA NETWORKS: FTP Server has new folder created daily for archiving -# recordings. If the directory does not exist, this script creates the directory in -# YYYYMMDD format. -# -# -# VERY IMPORTANT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -# You must be saving recordings as FULLDATE_CUSTPHONE_CAMPAIGN_AGENT -# and save files to dated-directories or this script will not work properly -# -# -# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 -# Contributions by Mike Lord -# Contributions by Magma Networks LLC -# -# 51021-1058 - Added quotes around CLI executed commands -# 51122-1455 - Added soxmix and sox binary path check -# 60616-1027 - Modified to convert to MP3 format -# - Creates Directory on target FTP server based on . -# 60807-1308 - Modified to use /etc/astguiclient.conf for settings -# 71004-1124 - Changed to not move ORIG recordings if FTP server does not Ping -# 71005-0049 - Altered script to use astguiclient.conf for settings -# - -#verbose -$v=0; -#test -$T=0; - -# Default variables for FTP -$VARFTP_host = '192.168.0.8'; -$VARFTP_user = 'recordings'; -$VARFTP_pass = 'recordings'; -$VARFTP_dir = '/var/www/html/RECORDINGS'; -$VARFTP_port = '21'; - - -# default path to astguiclient configuration file: -$PATHconf = '/etc/astguiclient.conf'; - -open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; -@conf = ; -close(conf); -$i=0; -foreach(@conf) - { - $line = $conf[$i]; - $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; - if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) - {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} - if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) - {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} - if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) - {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} - if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) - {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} - if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) - {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} - if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) - {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} - if ( ($line =~ /PATHDONEmonitor/) && ($CLIDONEmonitor < 1) ) - {$PATHDONEmonitor = $line; $PATHDONEmonitor =~ s/.*=//gi;} - if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) - {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) - {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) - {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) - {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) - {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) - {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) ) - {$VARFTP_host = $line; $VARFTP_host =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) ) - {$VARFTP_user = $line; $VARFTP_user =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) ) - {$VARFTP_pass = $line; $VARFTP_pass =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) ) - {$VARFTP_port = $line; $VARFTP_port =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) ) - {$VARFTP_dir = $line; $VARFTP_dir =~ s/.*=//gi;} - if ( ($line =~ /^VARHTTP_path/) && ($CLIHTTP_path < 1) ) - {$VARHTTP_path = $line; $VARHTTP_path =~ s/.*=//gi;} - $i++; - } - -# Customized Variables -$server_ip = $VARserver_ip; # Asterisk server IP - -### directory where in/out recordings are saved to by Asterisk -$dir1 = "$PATHmonitor"; -$dir2 = "$PATHDONEmonitor"; - -# get current date in the format YYYYMMDD for use in directory name on the storage server -($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); -my $today = sprintf("%d%02d%02d", $year + 1900, $mon + 1, $mday); - -$soxmixbin = ''; -if ( -e ('/usr/bin/soxmix')) {$soxmixbin = '/usr/bin/soxmix';} -else - { - if ( -e ('/usr/local/bin/soxmix')) {$soxmixbin = '/usr/local/bin/soxmix';} - else - { - print "Can't find soxmix binary! Exiting...\n"; - exit; - } - } -$lamebin = ''; -if ( -e ('/usr/bin/lame')) {$lamebin = '/usr/bin/lame';} -else - { - if ( -e ('/usr/local/bin/lame')) {$lamebin = '/usr/local/bin/lame';} - else - { - print "Can't find lame binary! Exiting...\n"; - exit; - } - } - -use Net::Ping; -use Net::FTP; - - - opendir(FILE, "$dir1/"); - @FILES = readdir(FILE); - -$i=0; -foreach(@FILES) - { - $size1 = 0; - $size2 = 0; - - if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) ) - { - - $size1 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size1\n";} - sleep(1); - $size2 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size2\n\n";} - - - if ( ($FILES[$i] !~ /out\.wav/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4)) - { - $INfile = $FILES[$i]; - $OUTfile = $FILES[$i]; - $OUTfile =~ s/-in\.wav/-out.wav/gi; - $ALLfile = $FILES[$i]; - $ALLfile =~ s/-in\.wav/-all.wav/gi; - $MP3file = $ALLfile; - $MP3file =~ s/-all\.wav/-all.mp3/gi; - - ### BEGIN Remote file transfer - $p = Net::Ping->new(); - $ping_good = $p->ping("$VARFTP_host"); - - if ($ping_good) - { - if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} - - `$soxmixbin "$dir1/$INfile" "$dir1/$OUTfile" "$dir2/$ALLfile"`; - if ($v) {print "|$INfile| |$OUTfile| |$ALLfile|\n\n";} - if (!$T) - { - `mv -f "$dir1/$INfile" "$dir2/ORIG/$INfile"`; - `mv -f "$dir1/$OUTfile" "$dir2/ORIG/$OUTfile"`; - } - - `$lamebin -b 16 -m m --silent "$dir2/$ALLfile" "$dir2/$MP3file"`; - - - if($DB){print STDERR "\n|$lamebin -b 16 -m m --silent \"$dir2/$ALLfile\" \"$dir2/$MP3file\"\n";} - chmod 0755, "$dir2/$MP3file"; - - $ftp = Net::FTP->new("$VARFTP_host", Port => $VARFTP_port, Debug => ($v? 1 : 0), Passive => 1); - $ftp->login("$VARFTP_user","$VARFTP_pass"); - #$ftp->cwd("$VARFTP_dir"); - $ftp->mkdir("$VARFTP_dir/$today", 1); - $ftp->cwd("$VARFTP_dir/$today"); - $ftp->binary(); - $ftp->put("$dir2/$MP3file", "$MP3file"); - $ftp->quit; - - # clean up - if (!$T) - { - `rm -f "$dir2/ORIG/$INfile"`; - `rm -f "$dir2/ORIG/$OUTfile"`; - `rm -f "$dir2/$ALLfile"`; - `rm -f "$dir2/$MP3file"`; - } - } - ### END Remote file transfer - } - } - $i++; - } - -if ($v) {print "DONE... EXITING\n\n";} - -exit; diff --git a/bin/AST_CRON_mix_recordings_VDonly_DATE.pl b/bin/AST_CRON_mix_recordings_VDonly_DATE.pl deleted file mode 100644 index bbd8363d..00000000 --- a/bin/AST_CRON_mix_recordings_VDonly_DATE.pl +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/perl -# -# AST_CRON_mix_recordings_VDonly_DATE.pl -# -# IMPORTANT!!! ONLY TO BE USED WHEN ONLY VICIDIAL RECORDINGS ARE ON THE SYSTEM! -# -# runs every 5 minutes and copies the -in recordings in the monitor to a dated -# directory on an FTP server. Creates the FTP directory if it does not exist. -# -# put an entry into the cron of of your asterisk machine to run this script -# every 5 minutes or however often you desire -# -# make sure that the following directories exist: -# /var/spool/asterisk/monitor # default Asterisk recording directory -# /var/spool/asterisk/monitor/ORIG # where the original in/out files are put -# -# This program assumes that recordings are saved as .wav -# should be easy to change this code if you use .gsm instead -# -# This program also sends the ALL combined file to an FTP server for archival -# purposes, you can comment out the Net::Ping and Net::FTP lines as well as the -# file transfer section of the code to deactivate remote copying of the -# recording files -# -# Copyright (C) 2007 Matt Florell LICENSE: GPLv2 -# -# -# 51021-1058 - Added quotes around CLI executed commands -# 51122-1458 - Added soxmix binary path check -# 60318-0921 - Added ability to mix gsm audio files -# 60807-1308 - Modified to use /etc/astguiclient.conf for settings -# 70702-1139 - Removed mixing, and added dated folder storage on FTP server -# 71004-1124 - Changed to not move ORIG recordings if FTP server does not Ping -# 71005-0049 - Altered script to use astguiclient.conf for settings -# - -# Default variables for FTP -$VARFTP_host = '10.0.0.4'; -$VARFTP_user = 'cron'; -$VARFTP_pass = 'test'; -$VARFTP_port = '21'; -$VARFTP_dir = 'RECORDINGS'; -$VARHTTP_path = 'http://10.0.0.4'; - - -# default path to astguiclient configuration file: -$PATHconf = '/etc/astguiclient.conf'; - -open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; -@conf = ; -close(conf); -$i=0; -foreach(@conf) - { - $line = $conf[$i]; - $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; - if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) - {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} - if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) - {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} - if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) - {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} - if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) - {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} - if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) - {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} - if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) - {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} - if ( ($line =~ /PATHDONEmonitor/) && ($CLIDONEmonitor < 1) ) - {$PATHDONEmonitor = $line; $PATHDONEmonitor =~ s/.*=//gi;} - if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) - {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) - {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) - {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) - {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) - {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} - if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) - {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) ) - {$VARFTP_host = $line; $VARFTP_host =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) ) - {$VARFTP_user = $line; $VARFTP_user =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) ) - {$VARFTP_pass = $line; $VARFTP_pass =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) ) - {$VARFTP_port = $line; $VARFTP_port =~ s/.*=//gi;} - if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) ) - {$VARFTP_dir = $line; $VARFTP_dir =~ s/.*=//gi;} - if ( ($line =~ /^VARHTTP_path/) && ($CLIHTTP_path < 1) ) - {$VARHTTP_path = $line; $VARHTTP_path =~ s/.*=//gi;} - $i++; - } - -# Customized Variables -$server_ip = $VARserver_ip; # Asterisk server IP -if (!$VARDB_port) {$VARDB_port='3306';} - -use DBI; - -$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") - or die "Couldn't connect to database: " . DBI->errstr; - - -### directory where in/out recordings are saved to by Asterisk -$dir1 = "$PATHmonitor"; -$dir2 = "$PATHDONEmonitor"; - -use Net::Ping; -use Net::FTP; - - opendir(FILE, "$dir1/"); - @FILES = readdir(FILE); - -$i=0; -foreach(@FILES) - { - $size1 = 0; - $size2 = 0; - - if ( (length($FILES[$i]) > 4) && (!-d $FILES[$i]) ) - { - - $size1 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size1\n";} - sleep(1); - $size2 = (-s "$dir1/$FILES[$i]"); - if ($v) {print "$FILES[$i] $size2\n\n";} - - if ( ($FILES[$i] !~ /out\.wav|out\.gsm/i) && ($size1 eq $size2) && (length($FILES[$i]) > 4)) - { - $INfile = $FILES[$i]; - $OUTfile = $FILES[$i]; - $OUTfile =~ s/-in\.wav/-out.wav/gi; - $OUTfile =~ s/-in\.gsm/-out.gsm/gi; - $ALLfile = $FILES[$i]; - $ALLfile =~ s/-in\.wav/-all.wav/gi; - $ALLfile =~ s/-in\.gsm/-all.gsm/gi; - $SQLFILE = $FILES[$i]; - $SQLFILE =~ s/-in\.wav|-in\.gsm//gi; - - $stmtA = "select recording_id,start_time from recording_log where filename='$SQLFILE' order by recording_id desc LIMIT 1;"; - if($DBX){print STDERR "\n|$stmtA|\n";} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_count=0; - while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - $recording_id = "$aryA[0]"; - $start_date = "$aryA[1]"; - $start_date =~ s/ .*//gi; - $rec_count++; - } - $sthA->finish(); - - if ($v) {print "|$INfile| |$ALLfile| |$recording_id|$start_date|\n";} - ### BEGIN Remote file transfer - $p = Net::Ping->new(); - $ping_good = $p->ping("$VARFTP_host"); - - if ($ping_good) - { - $ftp = Net::FTP->new("$VARFTP_host", Port => $VARFTP_port); - $ftp->login("$VARFTP_user","$VARFTP_pass"); - $ftp->cwd("$VARFTP_dir"); - $ftp->mkdir("$start_date"); - $ftp->cwd("$start_date"); - $ftp->binary(); - $ftp->put("$dir1/$INfile", "$ALLfile"); - $ftp->quit; - - $stmtA = "UPDATE recording_log set location='$VARHTTP_path/$start_date/$ALLfile' where recording_id='$recording_id';"; - if($DB){print STDERR "\n|$stmtA|\n";} - $affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n"; - - if (!$T) - { - `mv -f "$dir1/$INfile" "$dir2/ORIG/$INfile"`; - `mv -f "$dir1/$OUTfile" "$dir2/ORIG/$OUTfile"`; - } - } - ### END Remote file transfer - } - } - $i++; - } - -if ($v) {print "DONE... EXITING\n\n";} - -$dbhA->disconnect(); - - -exit;