如何在Ajax中执行Perl脚本?

时间:2014-11-16 11:28:22

标签: ajax perl mod-perl

我有一个小的Perl脚本来拨打号码。每当我手动执行它,它都能正常工作。另一方面,当我通过Web浏览器执行时,它会抛出错误。

#!/usr/bin/perl -w

#perl1.pl

use strict;

use CGI;
my $cgi = new CGI;
use CGI::Carp qw(fatalsToBrowser);

my $context="Test";

print $cgi->header();
print $cgi->start_html('Asterisk Caller');
print '<center><p>call</p>';

$dest_nmbr =~ s/ //g;  # delete the space in number

open FH, ">/var/spool/asterisk/outgoing/meeting_user$$.call" or print "<h2>error: $!<\/h2>";

print FH "Channel: GSM/1/xxxxxxxxx\n";
print FH "Callerid: 4006\n";
print FH "RetryTime: 60\n";
print FH "WaitTime: 30\n";
print FH "Context: $context\n";
print FH "Extension: s\n";
close FH;

print "<p><b>$dest_nmbr<\/b> &uuml;ber <b>$src_nmbr<\/b><\/p>";

我有代码使用Ajax中的Get Function来拨打Perl脚本。

 if(ajaxRequest != null)
                        {
                        ajaxRequest.open("GET", "-e dial1.pl" +  queryString , true);
                        ajaxRequest.onreadystatechange = handler;
                        //console.log(queryObj.fund);
                        ajaxRequest.send(null);
                        }
                else
                        {
                        window.console.log("AJAX (XMLHTTP) not supported.");
                        }

                }

我面临的错误是

[Mon Nov 17 04:26:52 2014] [error] slurp_filename('/var/www/perl/-e dial1.pl') / opening: (2) No such file or directory at /usr/lib64/perl5/vendor_perl/ModPerl/RegistryCooker.pm line 541

如果我做错了,请告诉我,我会很感激你的建议。

0 个答案:

没有答案
相关问题