ActiveState Community

WScript and Perl

Posted by mironduplessis on 2009-08-20 00:56

Hi,

I am relatively new to Perl and i am trying to alter a radius user experience script to work successfully when run from a windows server.

The thing is when I run the modified perl script only using perl then the script successfully connects to the radius server passes the username and password for authentication and returns the expected status code.

However because the application I am trying to run the script from uses WScript/Cscript to initialise the script it does not work 100%. Essentially it appears that if you run a simple perl script with no external calls using CScript it works successfully but any perl script which calls other modules/libraries does not.

The tests are shown below.

Basically if i run the following two tests from the command line:

*********TEST1**********

cscript //E:PerlScript c:\"Perl Code"\test1.pl

#code from test1.pl

print "Hello";

WScript->Quit(2)

I will receive the following output.

Hello

(check error code)

c:\ echo %ERRORLEVEL%

2 (Response)

*********TEST2**********

cscript //E:PerlScript c:\"Perl Code"\test2.pl

#code from test2.pl
use Authen::Radius;

$r = new Authen::Radius(Host => "xxx.xxx.xxx.xxx:1812", Secret => "xxx
+x");

$s = $r->check_pwd("monitor", "xxxx");
if ($s == 1)
{
print "Message:Success \n";
print "Statistic:0 \n";

$WScript->Quit(0);

}
else
{
print "Message:Failure \n";
print "Statistic:1 \n";

$WScript->Quit(1);
}

exit 0;

I will receive the following output:

Message: Success

Statistic: 0

Server Teminated Script.

(check error code)

c:\ echo %ERRORLEVEL%

-1073741785 (response)

*******************************

So then my question is what causes the script to terminate with that error code. From what I can see if i remove the statements which refer to the sub modules within radius.pm the script does not return that error code, however then obviously the functionality of the script is lost and therefore useless. Im sure i am doing something obviously wrong. Does anyone know what I should be doing.

Kind Regards

Miron