Page 241 - Asterisk™: The Future of Telephony
P. 241

print STDERR "4.  Testing 'saynumber'...";
                   print "SAY NUMBER 192837465 \"\"\n";
                   my $result = <STDIN>;
                   &checkresult($result);
               This test sends Asterisk the SAY NUMBER command. This command behaves identically
               to the SayNumber() dialplan application. It takes two arguments:
                 • The number to say
                 • The digits that may interrupt the command
               Again, since we’re not passing in any digits as the second argument, we need to pass
               in an empty set of quotes.
                   print STDERR "5.  Testing 'waitdtmf'...";
                   print "WAIT FOR DIGIT 1000\n";
                   my $result = <STDIN>;
                   &checkresult($result);
               This test shows the WAIT FOR DIGIT command. This command waits the specified num-
               ber of milliseconds for the caller to enter a DTMF digit. If you want the command to
               wait indefinitely for a digit, use -1 as the timeout. This application returns the decimal
               ASCII value of the digit that was pressed.
                   print STDERR "6.  Testing 'record'...";
                   print "RECORD FILE testagi gsm 1234 3000\n";
                   my $result = <STDIN>;
                   &checkresult($result);
               This section of code shows us the RECORD FILE command. This command is used to
               record the call audio, similar to the Record() dialplan application. RECORD FILE takes
               seven arguments, the last three of which are optional:
                 • The filename of the recorded file.
                 • The format in which to record the audio.
                 • The digits that may interrupt the recording.
                 • The timeout (maximum recording time) in milliseconds, or -1 for no timeout.
                 • The number of samples to skip before starting the recording (optional).
                 • The word BEEP, if you’d like Asterisk to beep before the recording starts (optional).
                 • The number of seconds before Asterisk decides that the user is done with the re-
                   cording and returns, even though the timeout hasn’t been reached and no DTMF
                   digits have been entered (optional). This argument must be preceded by s=.
               In this particular case, we’re recording a file called testagi (in the GSM format), with
               any of the DTMF digits 1 through 4 terminating the recording, and a maximum re-
               cording time of 3,000 milliseconds.
                   print STDERR "6a.  Testing 'record' playback...";
                   print "STREAM FILE testagi \"\"\n";




                                                                   Writing AGI Scripts in Perl | 213
   236   237   238   239   240   241   242   243   244   245   246