If anybody is interested, I wrote a short perl script to move call
recordings off of my astlinux system.  It checks to see if the last
modify time is greater than two minutes, assumes the recording is
complete, moves the file via ftp and then removes the file, saving
precious storage space on my keydisk.  I run it from cron every
fifteen minutes.

I've pasted it below.  If anybody can suggest improvements, I'd love
to hear them.

Thanks - Tom
===========================================================

#!/usr/bin/perl

# Move MixMonitor recordings from the /var/spool/asterisk/monitor
directory to ftp host
# checks the last modification date of the files and moves them if
they haven't been modified
# for at least two minutes, in which case is should be safe to assume
they are closed.
#
# deletes files once they have been moved.

use Net::FTP;

my @files;
my $dev;
my $ino;
my $mode;
my $nlink;
my $uid;
my $gid;
my $rdev;
my $size;
my $atime;
my $mtime;
my $ctime;
my $blksize;
my $blocks;

# open connection to ftp host

$ftp = Net::FTP->new("192.168.1.11", Debug => 0)
      or die "Cannot connect to 192.168.1.11: $@";

$ftp->login("anonymous",'-anonymous@')
      or die "Cannot login ", $ftp->message;

$ftp->binary;

# change the working diretory to where the monitor files are stored

chdir "/var/spool/asterisk/monitor" or die "\ncannot chdir to
/var/spool/asterisk: $!";

# get a list of filenames contained in the directory

opendir DH, "/var/spool/asterisk/monitor" or die "\ncannot get
directory listing: $!\n\n";

@files = readdir DH;

closedir DH;

# look at the date and time of each file.  If older than two minutes,
ftp to another server

foreach (@files){
  if ($_ =~ /^\../) {   # skip any files beginning with dot or dotdot
even thouth
                        # they're unlikely to have been created in the last two 
minutes
    next;
  }
  
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)
= stat $_;
  if ((time - $mtime) > 120 ) {
    $ftp->put($_);
    unlink "$_";
  }
}

$ftp->quit;

_______________________________________________
Astlinux-users mailing list
[email protected]
http://lists.kriscompanies.com/mailman/listinfo/astlinux-users

Donations to support AstLinux are graciously accepted via PayPal to [EMAIL 
PROTECTED]

Reply via email to