user3912021
user3912021

Reputation: 11

Catch OS exception when Javascript calls Perl script

I have a Java script (say) a.js that calls a Perl script b.pl by:

JavaScript:xmlhttpPost("http://:/cgi-bin/b.pl");

xmlhttpPost is something like:

function xmlhttpPost(strURL)
{
    var xmlHttpReq=createXMLHttpRequest();
    xmlHttpReq.open('POST', noCache(strURL), true);

where createXMLHttpRequest creates ActiveXObject

b.pl calls another perl module, c.pm. In c.pm, there is a piece of code to catch OS exception:

eval {
    $ftp->put($filenamepath); };
if ($@) {
    return "FTP time-out"; }

$ftp leverages Net::FTP.

If I run b.pl from command line and there is a time-out exception when using ftp to put a file, the excpetion was caught correctly. However, if b.pl is run via a.js, the time-out exception was not caught.

Please advise. Thanks!

Upvotes: 1

Views: 33

Answers (1)

AgileDan
AgileDan

Reputation: 361

I would consider looking into CGI::Carp. There appear to be to be several different methods that might interest you in that documentation.

Upvotes: 0

Related Questions