[asterisk-users] Playback all the sound files

Danny Nicholas danny at debsinc.com
Fri Apr 23 12:43:38 CDT 2010


This is tested in 1.4.30
#!/usr/bin/perl
#
# allfiles 1.0
#
# reads all of the files in /var/lib/asterisk/sounds/en and plays on the
line
# while showing name on console (CLI)
# save as at: /var/lib/asterisk/agi-bin/allfiles.agi  Be sure to chmod +x
it!
#
# Invocation Example:
#   exten => 68742,1,Answer()
#   exten => 68742,2,agi,allfiles.agi|/var/lib/asterisk/sounds/en
#   exten => 68742,3,Hangup()
#
use strict;

$|=1;

# Setup some variables
my %AGI; my $tests = 0; my $fail = 0; my $pass = 0;
my @masterCacheList = ();
my $maxNumber = 10;

# setup options
my $FILEDIR = $ARGV[0];
if (! $FILEDIR ) {
   $FILEDIR = '/var/lib/asterisk/sounds/en';
   }

  opendir (SOUNDDIR, "$FILEDIR") or
      die "Cannot open report dir $FILEDIR.";
   while (defined(my $file = readdir(SOUNDDIR))) {
      next if $file !~ /\.gsm/;
      print STDERR "play file $file\n";
      my @split_file_name = split /\./, $file;
      my $playfile = $split_file_name[0];
      print STDOUT "EXEC BACKGROUND $FILEDIR/$playfile\n";
      my $result = <STDIN>; &check_result($result);
      }
   closedir (SOUNDDIR) or
      die "Can't close report dir $FILEDIR.";

exit 0;
sub check_result {
   my ($res) = @_;
   my $retval;
   $tests++;
   if ($res =~ /^200/) {
      return 1;
      }
   else {
      return 0;
      }
   }

Don't know how it will post, but PERL doesn't really care about the spacing
and it's just a Q&D.

-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Jian Gao
Sent: Friday, April 23, 2010 12:12 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: [asterisk-users] Playback all the sound files

Hello.

There are so many sound files in /var/lib/asterisk/en.  Is there an easy 
way to let me play back all of them one by one while I am watching CLI 
to see the current file name?

Thanks for help.
-- 
Jian Gao
IT Technician
SJ Geophysics Ltd. <http://www.sjgeophysics.com>
jian.gao at sjgeophysics.com <mailto:jian.gao at sjgeophysics.com>
Tel: (604)582-1100

-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users




More information about the asterisk-users mailing list