Forum Moderators: coopster & phranque

Message Too Old, No Replies

Shifting Perl Script - Fedora to Windows Server 2003

         

Ustad_Ji

11:19 am on Aug 12, 2014 (gmt 0)

10+ Year Member



I have a Perl script embedded in an HTML page on a Fedora machine which I need to move to another server running Windows Server 2003. I have moved the HTML page without much trouble but the Perl script ain't working. The script by the way is used for fetching cable modem stats - parameters like Power Level, SNR etc.
Now how do I go about getting the script to work on Windows Server 2003?

Brett_Tabke

11:37 am on Aug 12, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



> embedded in an HTML page

Unless it is ModPerl, Perl is not generlly "embedded" in an html file. If it is ModPerl - then you need to make sure your new host is running ModPerl.

If it is not ModPerl, then the perl script is actually a stand alone script, that can be test on the new machine.

What is the code that calls the perl script?

Ustad_Ji

12:51 pm on Aug 12, 2014 (gmt 0)

10+ Year Member



-----------------------
<HTML>
<BODY BACKGROUND="//200.100.100.100/bg.jpg"><H3>Please Click on your desired link</H3></BODY>
<A HREF="http://mis.jangomango.net/its/login.asp"> <h5>IT Help Desk</h5>
<A HREF="http://mis.jangomango.net/NAMS/Login.aspx"> <h5>Network Alarm Management System</h5>
<A HREF="/cgi-bin/cmonitor.pl"> <h5>Cable Modem Signal Status</h5>
</HTML>

-----------------------

Above is the code for HTML page index.html and cmonitor.pl is the script.

Following is the code for script cmonitor.pl:
-----------------------
[root@localhost cgi-bin]# cat cmonitor.pl
#!/usr/bin/perl -w

#use strict;

#my $version = 'v1.2';
#my $date = '14-Oct-2001';

# Free software - GNU GPL - AS IS, NO WARRANTY...
# please keep author's (my) reference...
#

# Setup:
# ------
# Rename the file to tracert.pl tracert.plx or similar based on the
# settings on your system
# and/or put it in a directory which is CGI enabled and make sure you have
# Perl enabled on the server for files with the extension you gave to the file
# Change the following variables to fit your site

# Name of the organization
my $orgname = 'Jango Mango';
#my $command = '/usr/sbin/traceroute'; # this is usually good for Linux and UNIX
#my $command = '/usr/local/bin/traceroute'; # this is also a good guess for UNIX systems
#my $command = 'c:\windows\trace.exe'; # this is a good guess on Windows machines

#Please send an

# You don't have to change anything further.
########################################
# v1.2
# add -wT during development
# use strict
# fix the security prolem: check the input before running traceroute
# options to run traceroute of OSs other than NT so this becomes a platform
# independent interface (bla bla bla)


$|=1;
$ENV{PATH}="/usr/local/net-snmp/bin:/usr/local/net-snmp/sbin:/bin:/usr/bin:/usr/local/bin";
#print $ENV;
print <<HTML;
Content-type: text/html

<html><head><title>Cable Modems Status</title></head><body bgcolor=white>
<h1>WorldCall Cable Modem Status</h1>
<br><b>Developed & Maintained by NOC</right></b><br>
<a href=$orghome> $orgname</a><p>
<font size=2><b For comments </b>
For Comments <b><a href=mailto:$crmail>Feedback</a></b></font><br>

<br><a href=http://200.100.100.100/cgi-bin/clg.cgi>Ping & Dns utilities</a><br>


HTML





#$command ='/var/www/cgi-bin/dmon';
$commandtip ='/var/www/cgi-bin/dmontip';

$qs = $ENV{QUERY_STRING};
#print "$qs";
#print "$qs";
#if (@ARGV) { $qs = $ARGV[0]; } # for command line testing only

if ((defined $qs) and ($qs ne "" )) {
if ($qs =~ /^t=(.*)/) {

$qs=$1;

}

if ( $qs =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ && !((1|$1|$2|$3|$4)&256) ) {

$ipqs=$qs;
print "<hr>";
print "<PRE>";
system "$commandtip $ipqs";
print "</PRE>";
print "<hr>";

}

else {
print "<hr>";
print "<PRE>";
system "$command $qs";
print "</PRE>";
print "<hr>";
}
}


print <<HTML;

Please type in CM IP Address to check the status and press ENTER
<font size=+2 color=blue>
<form>
<input name=t>
</form>

HTML
#<ISINDEX>

-----------------------

Brett_Tabke

3:48 pm on Aug 12, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



just login to a shell comand line and get to the directory that has the script.

then do
perl -cw cmonitor.pl:

to see if the script runs. Probably a permissions issu.

phranque

9:51 am on Aug 23, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, Ustad_Ji!


I have a Perl script embedded in an HTML page
<A HREF="/cgi-bin/cmonitor.pl"> <h5>Cable Modem Signal Status</h5>

technically, that would be "linked from", not "embedded in" an html page.

have you installed perl on the server?
you will probably need ActivePerl for Windows:
http://www.activestate.com/activeperl [activestate.com]

Hoople

12:49 am on Aug 24, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



With Windows 2003 support ending soon would it not be advisable to use Server 2008 R2 instead?

It can be setup more securely as a 'headless' (no desktop) server too.