Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Script not able to work on Server 2003

Reply
Thread Tools

Script not able to work on Server 2003

 
 
Joe
Guest
Posts: n/a
 
      10-07-2007
I have PERL scripst that I created on a Windows 2000 Server, that work
great. We switched to a Windows 2003 Server, PERL is installed, but my
script that works on 2000, will not work with the 2003 server. I keep
getting the following error on all my scripts:

"Content-type: text/html

'C:\Inetpub\wwwroot\cgi-bin\Employee_Status\employee_status.cgi'
script produced no output"

Plus, I have tried changing the extension to cgi, and I get the same
error.

Does anyone have any suggestions for me? I'm almost positive it is
something simple, but I am just not seeing it.

 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      10-07-2007
Joe <> wrote:
> I have PERL scripst that I created on a Windows 2000 Server, that work
> great. We switched to a Windows 2003 Server, PERL is installed, but my
> script that works on 2000, will not work with the 2003 server. I keep
> getting the following error on all my scripts:
>
> "Content-type: text/html
>
> 'C:\Inetpub\wwwroot\cgi-bin\Employee_Status\employee_status.cgi'
> script produced no output"
>
> Plus, I have tried changing the extension to cgi, and I get the same
> error.
>
> Does anyone have any suggestions for me? I'm almost positive it is
> something simple, but I am just not seeing it.



I'm almost positive it has nothing to do with Perl.

It likely has to do with web server configuration.

Ask in a newsgroup about web servers.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
 
Reply With Quote
 
 
 
 
Joe
Guest
Posts: n/a
 
      10-07-2007
Good suggestion, but the one thing I forgot to mention is, another
person wrote scripts a few years ago, and those, basically work out of
the box. His and mine are somewhat identical, but his work and mine
don't.

I have check for differences in coding style, and some we are fairly
close and other note. The big difference from his and mine are that
most of his are links in .asp pages, mine are just straight links.

Possibly it has something to do with the way IIS is calling it. Most
of my scripts do not have much to do with IIS. I'm sorry I'm rabling,
I just been looking at this all weekend.

 
Reply With Quote
 
Ron Bergin
Guest
Posts: n/a
 
      10-08-2007
On Oct 7, 3:23 pm, Joe <jruff...@gailborden.info> wrote:
> Good suggestion, but the one thing I forgot to mention is, another
> person wrote scripts a few years ago, and those, basically work


Without seeing you coder and knowing how your web server is
configured, it's anyones guess as to the problem/solution.

> His and mine are somewhat identical, but his work ....

^^^^^^^^^^^^^^^^^^
That's probably the key. What's the difference between yours and his?

>
> I have check for differences in coding style, and some we are fairly
> close and other note. The big difference from his and mine are that
> most of his are links in .asp pages, mine are just straight links.


Show us your code. Style is just style, what it's doing is most
important. We may not be able to troubleshoot the asp side, but if we
see your Perl code, we may be able to find the problem/solution.
>
> Possibly it has something to do with the way IIS is calling it.

That may be the case, and if so, we'll probably direct you to posting
in an IIS forum, but without seeing your code, it's impossible to say.

 
Reply With Quote
 
Joe
Guest
Posts: n/a
 
      10-08-2007
Here is my code, I picked one of my shorter scripts:

<code>#!/usr/bin/perl -w

# Joe Ruffino Daily WebOpac.pl
# This program will read in a text file, and print it out
# in table format
# Written: January 30, 2004
# Revised: December 09, 2004, Jan 03, 2005

use CGI qw(:standard :html3);
use CGI::Carp qw(fatalsToBrowser);
use strict;


################################################## ########################
# Set Variables
#

my $ip_hold = 0;
my $sec;
my $min;
my $hour;
my $day;
my $month;
my $year;
my $ip_list;
my $monthfind;
my $monthm;
my $countip;

my $stationip;
my $stationname;

my @stationip;
my @stationname;

my $dayopac;
my $daym;
my $dayopacm;
my $dayfind;
my $headerpage;
my $dayflag;
my $namev;
my $one;
my $two;
my $three;
my $monthcurr;
my $monthnow;
my $countin;
my $countout;
my $ip;
my $date;
my $time;
my $firstp;
my $secondp;
my $thirdp;
my $fourthp;
my $firstip;
my @firstip;
my $sn;
my $count;
my $date_month;
my $date_day;
my $date_year;
my $i;
my $ips;
my @Names;
my %Names;
my $ext_ip;
my %seen;
my $countint;
my $totalcnt;
my $totalline;
my $station_name;
my @opacline;
my %count;
my @staionip;
my $line;
my $opac_month;
my $hold_date;
my $date_cnt;
my $ip_day_cnt;
my $day_array;
my $ip_day_cnt;
my $four;
my @ext_line;
my %day_array;
my %letters;
my $tot_ip_cnt;
my $ip_cnt;
my $four;

################################################## ########################
# Subroutine for finding the text month when numerical month is given
#
sub dayfind {

#Setup date field
if ($dayopacm eq "01") {
$dayfind = "January"; }

if ($dayopacm eq "02") {
$dayfind = "February"; }

if ($dayopacm eq "03") {
$dayfind = "March"; }

if ($dayopacm eq "04") {
$dayfind = "April"; }

if ($dayopacm eq "05") {
$dayfind = "May"; }

if ($dayopacm eq "06") {
$dayfind = "June"; }

if ($dayopacm eq "07") {
$dayfind = "July"; }

if ($dayopacm eq "08") {
$dayfind = "August"; }

if ($dayopacm eq "09") {
$dayfind = "September"; }

if ($dayopacm eq "10") {
$dayfind = "October"; }

if ($dayopacm eq "11") {
$dayfind = "November"; }

if ($dayopacm eq "12") {
$dayfind = "December"; }
return $dayfind;
}

################################################## ########################
# Subroutine for finding the numerical month when text month is given
#
sub monthfind {

#Setup date field
if ($monthm eq "Jan") {
$monthfind = "01"; }

if ($monthm eq "Feb") {
$monthfind = "02"; }

if ($monthm eq "Mar") {
$monthfind = "03"; }

if ($monthm eq "Apr") {
$monthfind = "04"; }

if ($monthm eq "May") {
$monthfind = "05"; }

if ($monthm eq "Jun") {
$monthfind = "06"; }

if ($monthm eq "Jul") {
$monthfind = "07"; }

if ($monthm eq "Aug") {
$monthfind = "08"; }

if ($monthm eq "Sep") {
$monthfind = "09"; }

if ($monthm eq "Oct") {
$monthfind = "10"; }

if ($monthm eq "Nov") {
$monthfind = "11"; }

if ($monthm eq "Dec") {
$monthfind = "12"; }
return $monthfind;
}

################################################## ########################
# Find current Time and Date info
#
($sec,$min,$hour,$day,$month,$year) = localtime(time);
$year = $year +1900;

# ignore used for testing
$ip_list = "OpacIP";
# ignore used for testing

################################################## ########################
# Open IP file and test data file
# Then split IP file into IP address and Station Name array's
#
open (LISTIN,"ipnew.txt") || die "Cannot Open File ipadd.txt for
reading: $!";

while (<LISTIN>) {
($staionip[$countip], $stationname[$countip]) = split(/\s+/);
$countip++;
}

$stationip = @stationip;
$stationname = $stationname;

close (LISTIN);


################################################## ########################
# If a file name has been given, process the file
#

$line = 0;
if (param()) {

# Set filename entered to a variable
my $dayopac = param("dayopac");

# Split file name into month and day by assuming a dash is there
($dayopacm, $daym) = split(/-/, $dayopac);
if ($daym) { # if there is a 2-digit day
$dayflag = "yes";

# find the text month by sending the 2-digit month
$monthfind = dayfind($dayopacm);
if ($monthfind eq "December") {
#$year = $year -1;
}
$headerpage = "Daily Stats for " . $monthfind . " " . $daym . ",
" . $year;
} else {

# if not a day to be procressed, check to see if it is a month
to
# be processed
$dayflag = "no";
$daym = "01";

# Split file name into process name and month by assuming an
# underscore is there
($namev, $monthm) = split(/_/, $dayopac);

# find the 2-digit month by sending the text month
$monthcurr = monthfind($monthm);

# if current month is equal to the month entered
if ($month eq $monthcurr) { # if it is 1 - 9
if ($month > 9) {
$dayopacm = $month; # set current month to month holder
} else {
# set current month to month holder and append a '0
$dayopacm = "0" . $month;
}
} else {
# if not equal set month entered to month holder
$dayopacm = $monthcurr;
}
# Go to subroutine to find the FULL text month
$monthnow = dayfind($dayopacm);
if ($monthnow eq "December") {
$year--;
}
($one, $two, $three, $four) = split(/\\/, $dayopac);

# Set title for HTML Output page using text month that was found
$headerpage = "Monthly Stats for $monthnow $year";
}

$ip_list .= "_" . $monthm .".txt";
open (OPAC_IP, ">$ip_list") || die "$ip_list open failed: $!";

$opac_month = $dayopac . "_" . $year . ".html";
open (OPAC_WEB, ">$opac_month") || die "$ip_list open failed: $!";

# Append .txt to filename given, and open file for reading
$dayopac .= ".txt";
open (OPAC,$dayopac) || die ($dayopac . " open failed: $!");

# Print title on new HTML page and first line
print OPAC_WEB <<END;
<HTML><HEAD>
<META name="description" content="GBPL Titles with Holds">
<META name="robots" content="nofollow">
<TITLE>WebOpac $headerpage</TITLE>
</HEAD>
<CENTER>
<H1>$headerpage</H1>
END

($ip,$date,$time,$sn) = split(/ +/);
$hold_date = $dayopacm . "-" . $daym . "-" . substr(($year - 1900),
1,2);

$countin = 0; # zero out counter for ip numbers used in an
array
$date_cnt = 0;
$ip_day_cnt = 0;

while (<OPAC>) {
chomp;
$countout++; # count number of records processed

($ip,$date,$time,$sn) = split(/ +/);

# If IP is internal, process
if ($ip =~ /192.168.33/) {

# Split IP in to 4 parts using a period
($firstp,$secondp,$thirdp,$fourthp) = split(/\./, $ip);

# If IP is between 1 and 9, append 00 to it
if ($fourthp > 0 && $fourthp < 10) {
$fourthp = "00" . $fourthp;
} else {

# If IP is between 10 and 99, append 0 to it
if ($fourthp > 9 && $fourthp < 100) {
$fourthp = "0" . $fourthp;
}
}
# Assign IP to an array element
$firstip[$countin] = $fourthp;

# Add 1 to array counter
$countin++;
} else {
if ($date ne $hold_date) {
foreach $ip (sort keys %day_array) {
$ip_day_cnt++;
}
$tot_ip_cnt += $ip_day_cnt;
$ext_line[$line] = "<b><i>" . $hold_date . "</b></i> has <b><i>" .
$ip_day_cnt . "</b></i> unique External IPs.<p>";
$date_cnt = 0;
$ip_day_cnt = 0;
%day_array = " ";
$line++;
}
$ext_ip++;
$letters{$ip} = 1;
$day_array{$ip} = 1;
$date_cnt++;
}
$hold_date = $date;
}

foreach $ip (sort keys %day_array) {
$ip_day_cnt++;
}
$tot_ip_cnt += $ip_day_cnt;
$ext_line[$line] = "<b><i>" . $hold_date . "</b></i> has <b><i>" .
$ip_day_cnt . "</b></i> unique External IPs.<p>";

# print OPAC_IP @Names;
close (OPAC_IP);

foreach $ip (sort keys %letters) {
$ip_cnt++;
}

#print "<p>$ip_cnt";
# Set length of array to variable
$countint = @firstip;

# Tally distinctive ips
foreach $ips(@firstip) {
$count{$ips}++;
}

foreach $ips(sort(keys %count)) {
for ($i = 0; $i <= $countip; $i++) {
if ($ips == $staionip[$i]) {
$opacline[$totalcnt] = "The Station <b><i>".$stationname[$i]."</i></
b> with IP <b><i>".$ips. "</i></b> has visited Opac <b><i>".
$count{$ips}."</i></b> times.\n";
$totalcnt++;
if ( $count{$ips} > $ip_hold) {
$ip_hold = $count{$ips};
$station_name = $i;
}
}

}
}
close(OPAC);

if ($countint == 0) { $totalcnt = 0;}

if ($dayflag eq "yes") {
$totalline = "There are <b><i> " . $totalcnt . "</i></b> total
patron stations used for <b><i>" . $monthfind . " " . $daym . "</i></
b>.";
} else {
$totalline = "There are <b><i> " . $totalcnt . "</i></b> total
patron stations used for the Month of <b><i>" . $monthnow . "</i></
b>.";
}
print OPAC_WEB hr();
print OPAC_WEB p("There are <b><i>" . $countint . "</i></b>
internal IP address hits.");
print OPAC_WEB p("There are <b><i>" . $ext_ip . "</i></b> external
IP address hits.");
# print p("There are <b><i>" . ($countout-$countin) . "</i></b>
external IP address hits.");
print OPAC_WEB p("There are <b><i>" . $countout . "</i></b> total
IP address hits.");
print OPAC_WEB p($totalline);
print OPAC_WEB p("The Station <b><i>".
$stationname[$station_name]."</i></b> has the greatest number of hits
of <b><i>".$ip_hold."</i></b> times.");
print OPAC_WEB p("There are <b><i>" . $tot_ip_cnt . "</i></b> Total
unique External IP hits for All Days in <b><i>$monthnow</i></b>.");
print OPAC_WEB p("There are <b><i>" . $ip_cnt . "</i></b> unique
External IP hits for the Month of <b><i>$monthnow</i></b>.");
print OPAC_WEB "<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">";
print OPAC_WEB "<A NAME=\"int\">Internal<\/A><\/font>";
print OPAC_WEB "<A HREF=\"\#ext\">External Hits<\/a> ";
print OPAC_WEB hr();

for ($i = 0; $i <= $totalcnt; $i++) {
print OPAC_WEB p($opacline[$i]);
}
print OPAC_WEB hr();
print OPAC_WEB "<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">";
print OPAC_WEB "<A NAME=\"ext\">External<\/A><\/font>";
print OPAC_WEB "<A HREF=\"\#int\">Internal Hits<\/a>";
print OPAC_WEB p(@ext_line);
print OPAC_WEB hr();
print OPAC_WEB "</center>";

use CGI; print redirect("$opac_month");
} else {

################################################## ########################
# If a file name has not been given, process the file, create webpage
to
# ask for it
#
print header, start_html("Monthly WebOpac"), h1("Monthly WebOpac
Report");

print hr();
print start_form();
print p("Day File: ",textfield("dayopac"), "<b> * form should be
WebOpac_(<i>3-letter Month</i></b>)");
# print p("Check Test: ",checkbox("opaccheck"));

print p(submit("Submit Entry"));
print end_form(), hr();
}

print end_html;</code>

 
Reply With Quote
 
Mumia W.
Guest
Posts: n/a
 
      10-09-2007
On 10/08/2007 06:10 PM, Joe wrote:
> Here is my code, I picked one of my shorter scripts:
>
> <code>#!/usr/bin/perl -w
>
> # Joe Ruffino Daily WebOpac.pl
> # This program will read in a text file, and print it out
> # in table format
> # Written: January 30, 2004
> # Revised: December 09, 2004, Jan 03, 2005
>
> use CGI qw(:standard :html3);
> use CGI::Carp qw(fatalsToBrowser);
> use strict;
>
>
> ################################################## ########################
> # Set Variables
> #
>
> my $ip_hold = 0;
> my $sec;
> my $min;
> my $hour;
> my $day;
> my $month;
> my $year;
> my $ip_list;
> my $monthfind;
> my $monthm;
> my $countip;
>
> my $stationip;
> my $stationname;
>
> my @stationip;
> my @stationname;
>
> my $dayopac;
> my $daym;
> my $dayopacm;
> my $dayfind;
> my $headerpage;
> my $dayflag;
> my $namev;
> my $one;
> my $two;
> my $three;
> my $monthcurr;
> my $monthnow;
> my $countin;
> my $countout;
> my $ip;
> my $date;
> my $time;
> my $firstp;
> my $secondp;
> my $thirdp;
> my $fourthp;
> my $firstip;
> my @firstip;
> my $sn;
> my $count;
> my $date_month;
> my $date_day;
> my $date_year;
> my $i;
> my $ips;
> my @Names;
> my %Names;
> my $ext_ip;
> my %seen;
> my $countint;
> my $totalcnt;
> my $totalline;
> my $station_name;
> my @opacline;
> my %count;
> my @staionip;
> my $line;
> my $opac_month;
> my $hold_date;
> my $date_cnt;
> my $ip_day_cnt;
> my $day_array;
> my $ip_day_cnt;
> my $four;
> my @ext_line;
> my %day_array;
> my %letters;
> my $tot_ip_cnt;
> my $ip_cnt;
> my $four;
>
> ################################################## ########################
> # Subroutine for finding the text month when numerical month is given
> #
> sub dayfind {
>
> #Setup date field
> if ($dayopacm eq "01") {
> $dayfind = "January"; }
>
> if ($dayopacm eq "02") {
> $dayfind = "February"; } [...]


Use data to simplify code (untested):

my @monthnames = qw(
January February March April May June
July August September October November December ) ;

my %monthnames;
@monthnames{ @monthnames } = 1 .. @monthnames ;

my %rMonthnames = reverse %monthnames;

sub dayfind {
$dayfind = $monthnames{$dayopacm};
}

sub monthfind {
$monthfind = $rMonthnames{$monthm};
sprintf('%02d', $monthfind);
}


>
> if ($dayopacm eq "03") {
> $dayfind = "March"; }
>
> if ($dayopacm eq "04") {
> $dayfind = "April"; }
>
> if ($dayopacm eq "05") {
> $dayfind = "May"; }
>
> if ($dayopacm eq "06") {
> $dayfind = "June"; }
>
> if ($dayopacm eq "07") {
> $dayfind = "July"; }
>
> if ($dayopacm eq "08") {
> $dayfind = "August"; }
>
> if ($dayopacm eq "09") {
> $dayfind = "September"; }
>
> if ($dayopacm eq "10") {
> $dayfind = "October"; }
>
> if ($dayopacm eq "11") {
> $dayfind = "November"; }
>
> if ($dayopacm eq "12") {
> $dayfind = "December"; }
> return $dayfind;
> }
>
> ################################################## ########################
> # Subroutine for finding the numerical month when text month is given
> #
> sub monthfind {
>
> #Setup date field
> if ($monthm eq "Jan") {
> $monthfind = "01"; }
>
> if ($monthm eq "Feb") {
> $monthfind = "02"; }
>
> if ($monthm eq "Mar") {
> $monthfind = "03"; }
>
> if ($monthm eq "Apr") {
> $monthfind = "04"; }
>
> if ($monthm eq "May") {
> $monthfind = "05"; }
>
> if ($monthm eq "Jun") {
> $monthfind = "06"; }
>
> if ($monthm eq "Jul") {
> $monthfind = "07"; }
>
> if ($monthm eq "Aug") {
> $monthfind = "08"; }
>
> if ($monthm eq "Sep") {
> $monthfind = "09"; }
>
> if ($monthm eq "Oct") {
> $monthfind = "10"; }
>
> if ($monthm eq "Nov") {
> $monthfind = "11"; }
>
> if ($monthm eq "Dec") {
> $monthfind = "12"; }
> return $monthfind;
> }
>
> ################################################## ########################
> # Find current Time and Date info
> #
> ($sec,$min,$hour,$day,$month,$year) = localtime(time);
> $year = $year +1900;
>
> # ignore used for testing
> $ip_list = "OpacIP";
> # ignore used for testing
>
> ################################################## ########################
> # Open IP file and test data file
> # Then split IP file into IP address and Station Name array's
> #
> open (LISTIN,"ipnew.txt") || die "Cannot Open File ipadd.txt for
> reading: $!";
>
> while (<LISTIN>) {
> ($staionip[$countip], $stationname[$countip]) = split(/\s+/);
> $countip++;
> }


Huh? Why do you advance the field counter ($countip) each time through
the loop? Now you get both a different record and a different field with
each iteration.

>
> $stationip = @stationip;
> $stationname = $stationname;
>
> close (LISTIN);
>
>
> ################################################## ########################
> # If a file name has been given, process the file
> #
>
> $line = 0;
> if (param()) {
>
> # Set filename entered to a variable
> my $dayopac = param("dayopac");
>
> # Split file name into month and day by assuming a dash is there
> ($dayopacm, $daym) = split(/-/, $dayopac);
> if ($daym) { # if there is a 2-digit day
> $dayflag = "yes";
>
> # find the text month by sending the 2-digit month
> $monthfind = dayfind($dayopacm);


Dayfind does not use any arguments from its argument list, yet you give
it an argument anyway--why?

> if ($monthfind eq "December") {
> #$year = $year -1;
> }
> $headerpage = "Daily Stats for " . $monthfind . " " . $daym . ",
> " . $year;
> } else {
>
> # if not a day to be procressed, check to see if it is a month
> to
> # be processed
> $dayflag = "no";
> $daym = "01";
>
> # Split file name into process name and month by assuming an
> # underscore is there
> ($namev, $monthm) = split(/_/, $dayopac);
>
> # find the 2-digit month by sending the text month
> $monthcurr = monthfind($monthm);
>
> # if current month is equal to the month entered
> if ($month eq $monthcurr) { # if it is 1 - 9
> if ($month > 9) {
> $dayopacm = $month; # set current month to month holder
> } else {
> # set current month to month holder and append a '0
> $dayopacm = "0" . $month;
> }
> } else {
> # if not equal set month entered to month holder
> $dayopacm = $monthcurr;
> }
> # Go to subroutine to find the FULL text month
> $monthnow = dayfind($dayopacm);
> if ($monthnow eq "December") {
> $year--;
> }
> ($one, $two, $three, $four) = split(/\\/, $dayopac);
>
> # Set title for HTML Output page using text month that was found
> $headerpage = "Monthly Stats for $monthnow $year";
> }
>
> $ip_list .= "_" . $monthm .".txt";
> open (OPAC_IP, ">$ip_list") || die "$ip_list open failed: $!";
>
> $opac_month = $dayopac . "_" . $year . ".html";
> open (OPAC_WEB, ">$opac_month") || die "$ip_list open failed: $!";
>
> # Append .txt to filename given, and open file for reading
> $dayopac .= ".txt";
> open (OPAC,$dayopac) || die ($dayopac . " open failed: $!");
>
> # Print title on new HTML page and first line
> print OPAC_WEB <<END;
> <HTML><HEAD>
> <META name="description" content="GBPL Titles with Holds">
> <META name="robots" content="nofollow">
> <TITLE>WebOpac $headerpage</TITLE>
> </HEAD>
> <CENTER>
> <H1>$headerpage</H1>
> END
>
> ($ip,$date,$time,$sn) = split(/ +/);
> $hold_date = $dayopacm . "-" . $daym . "-" . substr(($year - 1900),
> 1,2);
>
> $countin = 0; # zero out counter for ip numbers used in an
> array
> $date_cnt = 0;
> $ip_day_cnt = 0;
>
> while (<OPAC>) {
> chomp;
> $countout++; # count number of records processed
>
> ($ip,$date,$time,$sn) = split(/ +/);
>
> # If IP is internal, process
> if ($ip =~ /192.168.33/) {
>
> # Split IP in to 4 parts using a period
> ($firstp,$secondp,$thirdp,$fourthp) = split(/\./, $ip);
>
> # If IP is between 1 and 9, append 00 to it
> if ($fourthp > 0 && $fourthp < 10) {
> $fourthp = "00" . $fourthp;
> } else {
>
> # If IP is between 10 and 99, append 0 to it
> if ($fourthp > 9 && $fourthp < 100) {
> $fourthp = "0" . $fourthp;
> }
> }
> # Assign IP to an array element
> $firstip[$countin] = $fourthp;
>
> # Add 1 to array counter
> $countin++;
> } else {
> if ($date ne $hold_date) {
> foreach $ip (sort keys %day_array) {
> $ip_day_cnt++;
> }
> $tot_ip_cnt += $ip_day_cnt;
> $ext_line[$line] = "<b><i>" . $hold_date . "</b></i> has <b><i>" .
> $ip_day_cnt . "</b></i> unique External IPs.<p>";
> $date_cnt = 0;
> $ip_day_cnt = 0;
> %day_array = " ";
> $line++;
> }
> $ext_ip++;
> $letters{$ip} = 1;
> $day_array{$ip} = 1;
> $date_cnt++;
> }
> $hold_date = $date;
> }
> [...]


I stopped reading here. The large number of global variables you used
and the large amount of text you posted make it not worth my while to
continue.

Your program is confusing because its functions are 10x the size they
need to be to get the job done, and you went hog-wild with the global
variables.

A debugger is available for Perl, but it'll cost you¹. However, creating
the right environment for the debugger will be a challenge. If you
haven't done so already, read the posting guidelines². They suggest
creating the shortest but runnable program that demonstrates your
problem; ninety per cent of the time, doing so reveals the bug.

--------------------
¹ $0.00. Try this: perl -d Web0pac.pl
² http://www.augustmail.com/~tadmc/clp...uidelines.html
 
Reply With Quote
 
John W. Krahn
Guest
Posts: n/a
 
      10-09-2007
Joe wrote:
> Here is my code, I picked one of my shorter scripts:
>
> <code>#!/usr/bin/perl -w
>
> # Joe Ruffino Daily WebOpac.pl
> # This program will read in a text file, and print it out
> # in table format
> # Written: January 30, 2004
> # Revised: December 09, 2004, Jan 03, 2005
>
> use CGI qw(:standard :html3);
> use CGI::Carp qw(fatalsToBrowser);
> use strict;
>
>
> ################################################## ########################
> # Set Variables
> #


You should declare your variables in the smallest scope possible instead of
all here.

[ SNIP ]


> ################################################## ########################
> # Subroutine for finding the text month when numerical month is given
> #
> sub dayfind {
>
> #Setup date field
> if ($dayopacm eq "01") {
> $dayfind = "January"; }


> ################################################## ########################
> # Subroutine for finding the numerical month when text month is given
> #
> sub monthfind {
>
> #Setup date field
> if ($monthm eq "Jan") {
> $monthfind = "01"; }


Just use hashes instead of subroutines:

my %dayfind = qw( 01 January 02 February 03 March 04 April 05 May 06 June 07
July 08 August 09 September 10 October 11 November 12 December );

my %monthfind = qw( Jan 01 Feb 02 Mar 03 Apr 04 May 05 Jun 06 Jul 07 Aug 08
Sep 09 Oct 10 Nov 11 Dec 12 );


> ################################################## ########################
> # Find current Time and Date info
> #
> ($sec,$min,$hour,$day,$month,$year) = localtime(time);
> $year = $year +1900;


You don't use $sec, $min, $hour or $day so:

my ( $month, $year ) = ( localtime )[ 4, 5 ];
$year += 1900;


> # ignore used for testing
> $ip_list = "OpacIP";
> # ignore used for testing
>
> ################################################## ########################
> # Open IP file and test data file
> # Then split IP file into IP address and Station Name array's
> #
> open (LISTIN,"ipnew.txt") || die "Cannot Open File ipadd.txt for
> reading: $!";
>
> while (<LISTIN>) {
> ($staionip[$countip], $stationname[$countip]) = split(/\s+/);
> $countip++;
> }
>
> $stationip = @stationip;
> $stationname = $stationname;


Shouldn't that be:

my $stationip = @stationip;
my $stationname = @stationname;

But you never use the variables $stationip and $stationname anyway.


> close (LISTIN);
>
>
> ################################################## ########################
> # If a file name has been given, process the file
> #
>
> $line = 0;
> if (param()) {
>
> # Set filename entered to a variable
> my $dayopac = param("dayopac");
>
> # Split file name into month and day by assuming a dash is there
> ($dayopacm, $daym) = split(/-/, $dayopac);
> if ($daym) { # if there is a 2-digit day
> $dayflag = "yes";
>
> # find the text month by sending the 2-digit month
> $monthfind = dayfind($dayopacm);
> if ($monthfind eq "December") {
> #$year = $year -1;
> }
> $headerpage = "Daily Stats for " . $monthfind . " " . $daym . ",
> " . $year;
> } else {
>
> # if not a day to be procressed, check to see if it is a month
> to
> # be processed
> $dayflag = "no";
> $daym = "01";
>
> # Split file name into process name and month by assuming an
> # underscore is there
> ($namev, $monthm) = split(/_/, $dayopac);
>
> # find the 2-digit month by sending the text month
> $monthcurr = monthfind($monthm);
>
> # if current month is equal to the month entered
> if ($month eq $monthcurr) { # if it is 1 - 9
> if ($month > 9) {
> $dayopacm = $month; # set current month to month holder
> } else {
> # set current month to month holder and append a '0
> $dayopacm = "0" . $month;
> }
> } else {
> # if not equal set month entered to month holder
> $dayopacm = $monthcurr;
> }


$monthcurr = $monthfind{ ( split /_/, $dayopac )[ 1 ] }
$dayopacm = sprintf '%02d', $month eq $monthcurr ? $month : $monthcurr;


> # Go to subroutine to find the FULL text month
> $monthnow = dayfind($dayopacm);


$monthnow = $dayfind{ $dayopacm };


> if ($monthnow eq "December") {
> $year--;
> }
> ($one, $two, $three, $four) = split(/\\/, $dayopac);


You never use these variables anywhere?


> # Set title for HTML Output page using text month that was found
> $headerpage = "Monthly Stats for $monthnow $year";
> }
>
> $ip_list .= "_" . $monthm .".txt";
> open (OPAC_IP, ">$ip_list") || die "$ip_list open failed: $!";
>
> $opac_month = $dayopac . "_" . $year . ".html";
> open (OPAC_WEB, ">$opac_month") || die "$ip_list open failed: $!";
>
> # Append .txt to filename given, and open file for reading
> $dayopac .= ".txt";
> open (OPAC,$dayopac) || die ($dayopac . " open failed: $!");
>
> # Print title on new HTML page and first line
> print OPAC_WEB <<END;
> <HTML><HEAD>
> <META name="description" content="GBPL Titles with Holds">
> <META name="robots" content="nofollow">
> <TITLE>WebOpac $headerpage</TITLE>
> </HEAD>
> <CENTER>
> <H1>$headerpage</H1>
> END
>
> ($ip,$date,$time,$sn) = split(/ +/);
> $hold_date = $dayopacm . "-" . $daym . "-" . substr(($year - 1900),
> 1,2);


$hold_date = sprintf '%s-%s-%02d', $dayopacm, $daym, $year % 100


> $countin = 0; # zero out counter for ip numbers used in an
> array
> $date_cnt = 0;
> $ip_day_cnt = 0;
>
> while (<OPAC>) {
> chomp;
> $countout++; # count number of records processed
>
> ($ip,$date,$time,$sn) = split(/ +/);
>
> # If IP is internal, process
> if ($ip =~ /192.168.33/) {


> if ( $ip =~ /^192\.168\.33/ ) {



> # Split IP in to 4 parts using a period
> ($firstp,$secondp,$thirdp,$fourthp) = split(/\./, $ip);


You never use $firstp, $secondp and $thirdp so ...


> # If IP is between 1 and 9, append 00 to it
> if ($fourthp > 0 && $fourthp < 10) {
> $fourthp = "00" . $fourthp;
> } else {
>
> # If IP is between 10 and 99, append 0 to it
> if ($fourthp > 9 && $fourthp < 100) {
> $fourthp = "0" . $fourthp;
> }
> }


$fourthp = sprintf '%03d', ( split /\./, $ip )[ 3 ];


> # Assign IP to an array element
> $firstip[$countin] = $fourthp;
>
> # Add 1 to array counter
> $countin++;
> } else {
> if ($date ne $hold_date) {
> foreach $ip (sort keys %day_array) {
> $ip_day_cnt++;
> }


$ip_day_cnt += keys %day_array;


> $tot_ip_cnt += $ip_day_cnt;
> $ext_line[$line] = "<b><i>" . $hold_date . "</b></i> has <b><i>" .
> $ip_day_cnt . "</b></i> unique External IPs.<p>";
> $date_cnt = 0;
> $ip_day_cnt = 0;
> %day_array = " ";
> $line++;
> }
> $ext_ip++;
> $letters{$ip} = 1;
> $day_array{$ip} = 1;
> $date_cnt++;
> }
> $hold_date = $date;
> }
>
> foreach $ip (sort keys %day_array) {
> $ip_day_cnt++;
> }


$ip_day_cnt += keys %day_array;


> $tot_ip_cnt += $ip_day_cnt;
> $ext_line[$line] = "<b><i>" . $hold_date . "</b></i> has <b><i>" .
> $ip_day_cnt . "</b></i> unique External IPs.<p>";
>
> # print OPAC_IP @Names;
> close (OPAC_IP);
>
> foreach $ip (sort keys %letters) {
> $ip_cnt++;
> }


$ip_cnt += keys %letters;


> #print "<p>$ip_cnt";
> # Set length of array to variable
> $countint = @firstip;
>
> # Tally distinctive ips
> foreach $ips(@firstip) {
> $count{$ips}++;
> }
>
> foreach $ips(sort(keys %count)) {
> for ($i = 0; $i <= $countip; $i++) {
> if ($ips == $staionip[$i]) {
> $opacline[$totalcnt] = "The Station <b><i>".$stationname[$i]."</i></
> b> with IP <b><i>".$ips. "</i></b> has visited Opac <b><i>".
> $count{$ips}."</i></b> times.\n";
> $totalcnt++;
> if ( $count{$ips} > $ip_hold) {
> $ip_hold = $count{$ips};
> $station_name = $i;
> }
> }
>
> }
> }
> close(OPAC);
>
> if ($countint == 0) { $totalcnt = 0;}
>
> if ($dayflag eq "yes") {
> $totalline = "There are <b><i> " . $totalcnt . "</i></b> total
> patron stations used for <b><i>" . $monthfind . " " . $daym . "</i></
> b>.";
> } else {
> $totalline = "There are <b><i> " . $totalcnt . "</i></b> total
> patron stations used for the Month of <b><i>" . $monthnow . "</i></
> b>.";
> }
> print OPAC_WEB hr();
> print OPAC_WEB p("There are <b><i>" . $countint . "</i></b>
> internal IP address hits.");
> print OPAC_WEB p("There are <b><i>" . $ext_ip . "</i></b> external
> IP address hits.");
> # print p("There are <b><i>" . ($countout-$countin) . "</i></b>
> external IP address hits.");
> print OPAC_WEB p("There are <b><i>" . $countout . "</i></b> total
> IP address hits.");
> print OPAC_WEB p($totalline);
> print OPAC_WEB p("The Station <b><i>".
> $stationname[$station_name]."</i></b> has the greatest number of hits
> of <b><i>".$ip_hold."</i></b> times.");
> print OPAC_WEB p("There are <b><i>" . $tot_ip_cnt . "</i></b> Total
> unique External IP hits for All Days in <b><i>$monthnow</i></b>.");
> print OPAC_WEB p("There are <b><i>" . $ip_cnt . "</i></b> unique
> External IP hits for the Month of <b><i>$monthnow</i></b>.");
> print OPAC_WEB "<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">";
> print OPAC_WEB "<A NAME=\"int\">Internal<\/A><\/font>";
> print OPAC_WEB "<A HREF=\"\#ext\">External Hits<\/a> ";
> print OPAC_WEB hr();
>
> for ($i = 0; $i <= $totalcnt; $i++) {
> print OPAC_WEB p($opacline[$i]);
> }
> print OPAC_WEB hr();
> print OPAC_WEB "<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">";
> print OPAC_WEB "<A NAME=\"ext\">External<\/A><\/font>";
> print OPAC_WEB "<A HREF=\"\#int\">Internal Hits<\/a>";
> print OPAC_WEB p(@ext_line);
> print OPAC_WEB hr();
> print OPAC_WEB "</center>";


Instead of 21 + $totalcnt calls to print() just print once:

print OPAC_WEB
hr(),
p( "There are <b><i>$countint</i></b> internal IP address hits." ),
p( "There are <b><i>$ext_ip</i></b> external IP address hits." ),
p( "There are <b><i>$countout</i></b> total IP address hits." ),
p( $totalline ),
p( "The Station <b><i>$stationname[$station_name]</i></b> has the
greatest number of hits of <b><i>$ip_hold</i></b> times." ),
p( "There are <b><i>" . $tot_ip_cnt . "</i></b> Total unique External
IP hits for All Days in <b><i>$monthnow</i></b>." ),
p( "There are <b><i>" . $ip_cnt . "</i></b> unique External IP hits
for the Month of <b><i>$monthnow</i></b>." ),
"<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">",
"<A NAME=\"int\">Internal<\/A><\/font>",
"<A HREF=\"\#ext\">External Hits<\/a> ",
hr(),
map( p( $opacline[ $_ ] ), 0 .. $totalcnt ),
hr(),
"<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">",
"<A NAME=\"ext\">External<\/A><\/font>",
"<A HREF=\"\#int\">Internal Hits<\/a>",
p( @ext_line ),
hr(),
"</center>";


> use CGI; print redirect("$opac_month");
> } else {
>
> ################################################## ########################
> # If a file name has not been given, process the file, create webpage
> to
> # ask for it
> #
> print header, start_html("Monthly WebOpac"), h1("Monthly WebOpac
> Report");
>
> print hr();
> print start_form();
> print p("Day File: ",textfield("dayopac"), "<b> * form should be
> WebOpac_(<i>3-letter Month</i></b>)");
> # print p("Check Test: ",checkbox("opaccheck"));
>
> print p(submit("Submit Entry"));
> print end_form(), hr();
> }
>
> print end_html;</code>



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
 
Reply With Quote
 
- Bob -
Guest
Posts: n/a
 
      10-09-2007
On Mon, 08 Oct 2007 16:10:46 -0700, Joe <>
wrote:

>Here is my code, I picked one of my shorter scripts:
>
><code>#!/usr/bin/perl -w
>
># Joe Ruffino Daily WebOpac.pl
># This program will read in a text file, and print it out
># in table format
># Written: January 30, 2004
># Revised: December 09, 2004, Jan 03, 2005


Joe:

I think you problems are simpler than examining your code. At the very
least, you need to check the basics.

Have you tried writing a VERY SIMPLE script and trying to get it to
run? If you get the same error from all of your scripts, then you have
a very basic configuration problem or testing problem. Write something
that just produces the HTML MIME header and some simple hardcoded
output. Test it in the EXACT same way that you are testing your more
complex code. Odds are that it will fail. Find the basic problem with
that an move from there.

One other test that's good to do is to run the program on the server
in a command window. Setting up post parameters can be an issue but
it's a good way to test the server. Simple programs (see above) should
run properly at a command prompt and the output should be exactly what
you get sent to the browser. If it's not, you have a server issue to
look for.

If you don't know how to see raw output back to the browser, ask,
there's a free MS program that will return all the raw output (or you
can use telnet).

 
Reply With Quote
 
Ron Bergin
Guest
Posts: n/a
 
      10-10-2007
John and Mumia have pointed out most of the problems, but here are
some more.

On Oct 8, 4:10 pm, Joe <jruff...@gailborden.info> wrote:
> Here is my code, I picked one of my shorter scripts:
>
> <code>#!/usr/bin/perl -w
>
> # Joe Ruffino Daily WebOpac.pl
> # This program will read in a text file, and print it out
> # in table format
> # Written: January 30, 2004
> # Revised: December 09, 2004, Jan 03, 2005
>
> use CGI qw(:standard :html3);
> use CGI::Carp qw(fatalsToBrowser);
> use strict;
>
> ################################################## ########################
> # Set Variables
> #
>
> my $ip_hold = 0;
> my $sec;
> my $min;
> my $hour;
> my $day;
> my $month;
> my $year;
> my $ip_list;
> my $monthfind;
> my $monthm;
> my $countip;
>
> my $stationip;
> my $stationname;
>
> my @stationip;
> my @stationname;
>
> my $dayopac;
> my $daym;
> my $dayopacm;
> my $dayfind;
> my $headerpage;
> my $dayflag;
> my $namev;
> my $one;
> my $two;
> my $three;
> my $monthcurr;
> my $monthnow;
> my $countin;
> my $countout;
> my $ip;
> my $date;
> my $time;
> my $firstp;
> my $secondp;
> my $thirdp;
> my $fourthp;
> my $firstip;
> my @firstip;
> my $sn;
> my $count;
> my $date_month;
> my $date_day;
> my $date_year;
> my $i;
> my $ips;
> my @Names;
> my %Names;
> my $ext_ip;
> my %seen;
> my $countint;
> my $totalcnt;
> my $totalline;
> my $station_name;
> my @opacline;
> my %count;
> my @staionip;
> my $line;
> my $opac_month;
> my $hold_date;
> my $date_cnt;
> my $ip_day_cnt;
> my $day_array;
> my $ip_day_cnt;
> my $four;
> my @ext_line;
> my %day_array;
> my %letters;
> my $tot_ip_cnt;
> my $ip_cnt;
> my $four;
>
> ################################################## ########################
> # Subroutine for finding the text month when numerical month is given
> #
> sub dayfind {
>
> #Setup date field
> if ($dayopacm eq "01") {
> $dayfind = "January"; }
>
> if ($dayopacm eq "02") {
> $dayfind = "February"; }
>
> if ($dayopacm eq "03") {
> $dayfind = "March"; }
>
> if ($dayopacm eq "04") {
> $dayfind = "April"; }
>
> if ($dayopacm eq "05") {
> $dayfind = "May"; }
>
> if ($dayopacm eq "06") {
> $dayfind = "June"; }
>
> if ($dayopacm eq "07") {
> $dayfind = "July"; }
>
> if ($dayopacm eq "08") {
> $dayfind = "August"; }
>
> if ($dayopacm eq "09") {
> $dayfind = "September"; }
>
> if ($dayopacm eq "10") {
> $dayfind = "October"; }
>
> if ($dayopacm eq "11") {
> $dayfind = "November"; }
>
> if ($dayopacm eq "12") {
> $dayfind = "December"; }
> return $dayfind;
>
> }
>
> ################################################## ########################
> # Subroutine for finding the numerical month when text month is given
> #
> sub monthfind {
>
> #Setup date field
> if ($monthm eq "Jan") {
> $monthfind = "01"; }
>
> if ($monthm eq "Feb") {
> $monthfind = "02"; }
>
> if ($monthm eq "Mar") {
> $monthfind = "03"; }
>
> if ($monthm eq "Apr") {
> $monthfind = "04"; }
>
> if ($monthm eq "May") {
> $monthfind = "05"; }
>
> if ($monthm eq "Jun") {
> $monthfind = "06"; }
>
> if ($monthm eq "Jul") {
> $monthfind = "07"; }
>
> if ($monthm eq "Aug") {
> $monthfind = "08"; }
>
> if ($monthm eq "Sep") {
> $monthfind = "09"; }
>
> if ($monthm eq "Oct") {
> $monthfind = "10"; }
>
> if ($monthm eq "Nov") {
> $monthfind = "11"; }
>
> if ($monthm eq "Dec") {
> $monthfind = "12"; }
> return $monthfind;
>
> }
>
> ################################################## ########################
> # Find current Time and Date info
> #
> ($sec,$min,$hour,$day,$month,$year) = localtime(time);
> $year = $year +1900;
>
> # ignore used for testing
> $ip_list = "OpacIP";
> # ignore used for testing
>
> ################################################## ########################
> # Open IP file and test data file
> # Then split IP file into IP address and Station Name array's
> #
> open (LISTIN,"ipnew.txt") || die "Cannot Open File ipadd.txt for
> reading: $!";
>
> while (<LISTIN>) {
> ($staionip[$countip], $stationname[$countip]) = split(/\s+/);
> $countip++;
>
> }
>
> $stationip = @stationip;
> $stationname = $stationname;
>
> close (LISTIN);
>
> ################################################## ########################
> # If a file name has been given, process the file
> #
>
> $line = 0;
> if (param()) {
>
> # Set filename entered to a variable
> my $dayopac = param("dayopac");
>
> # Split file name into month and day by assuming a dash is there
> ($dayopacm, $daym) = split(/-/, $dayopac);
> if ($daym) { # if there is a 2-digit day
> $dayflag = "yes";
>
> # find the text month by sending the 2-digit month
> $monthfind = dayfind($dayopacm);
> if ($monthfind eq "December") {
> #$year = $year -1;
> }
> $headerpage = "Daily Stats for " . $monthfind . " " . $daym . ",
> " . $year;
> } else {
>
> # if not a day to be procressed, check to see if it is a month
> to
> # be processed
> $dayflag = "no";
> $daym = "01";
>
> # Split file name into process name and month by assuming an
> # underscore is there
> ($namev, $monthm) = split(/_/, $dayopac);
>
> # find the 2-digit month by sending the text month
> $monthcurr = monthfind($monthm);
>
> # if current month is equal to the month entered
> if ($month eq $monthcurr) { # if it is 1 - 9
> if ($month > 9) {
> $dayopacm = $month; # set current month to month holder
> } else {
> # set current month to month holder and append a '0
> $dayopacm = "0" . $month;
> }
> } else {
> # if not equal set month entered to month holder
> $dayopacm = $monthcurr;
> }
> # Go to subroutine to find the FULL text month
> $monthnow = dayfind($dayopacm);
> if ($monthnow eq "December") {
> $year--;
> }
> ($one, $two, $three, $four) = split(/\\/, $dayopac);
>
> # Set title for HTML Output page using text month that was found
> $headerpage = "Monthly Stats for $monthnow $year";
> }
>
> $ip_list .= "_" . $monthm .".txt";
> open (OPAC_IP, ">$ip_list") || die "$ip_list open failed: $!";
>
> $opac_month = $dayopac . "_" . $year . ".html";
> open (OPAC_WEB, ">$opac_month") || die "$ip_list open failed: $!";
>
> # Append .txt to filename given, and open file for reading
> $dayopac .= ".txt";
> open (OPAC,$dayopac) || die ($dayopac . " open failed: $!");
>
> # Print title on new HTML page and first line
> print OPAC_WEB <<END;


1) You're not specifing the DOCTYPE
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

> <HTML><HEAD>
> <META name="description" content="GBPL Titles with Holds">
> <META name="robots" content="nofollow">
> <TITLE>WebOpac $headerpage</TITLE>
> </HEAD>


2) You're missing the opening body tag.
3) HTML tags should be in lowercase, not uppercase.

> <CENTER>

4) The <CENTER> tag is deprecated.

> <H1>$headerpage</H1>
> END


5) Dynamicaly creating a static html file that you later redirect to
doesn't make sense. Skip the file creation and just output your page.

>
> ($ip,$date,$time,$sn) = split(/ +/);
> $hold_date = $dayopacm . "-" . $daym . "-" . substr(($year - 1900),
> 1,2);
>
> $countin = 0; # zero out counter for ip numbers used in an
> array
> $date_cnt = 0;
> $ip_day_cnt = 0;
>
> while (<OPAC>) {
> chomp;
> $countout++; # count number of records processed
>
> ($ip,$date,$time,$sn) = split(/ +/);
>
> # If IP is internal, process
> if ($ip =~ /192.168.33/) {
>
> # Split IP in to 4 parts using a period
> ($firstp,$secondp,$thirdp,$fourthp) = split(/\./, $ip);
>
> # If IP is between 1 and 9, append 00 to it
> if ($fourthp > 0 && $fourthp < 10) {
> $fourthp = "00" . $fourthp;
> } else {
>
> # If IP is between 10 and 99, append 0 to it
> if ($fourthp > 9 && $fourthp < 100) {
> $fourthp = "0" . $fourthp;
> }
> }
> # Assign IP to an array element
> $firstip[$countin] = $fourthp;
>
> # Add 1 to array counter
> $countin++;
> } else {
> if ($date ne $hold_date) {
> foreach $ip (sort keys %day_array) {
> $ip_day_cnt++;
> }
> $tot_ip_cnt += $ip_day_cnt;
> $ext_line[$line] = "<b><i>" . $hold_date . "</b></i> has <b><i>" .
> $ip_day_cnt . "</b></i> unique External IPs.<p>";
> $date_cnt = 0;
> $ip_day_cnt = 0;
> %day_array = " ";
> $line++;
> }
> $ext_ip++;
> $letters{$ip} = 1;
> $day_array{$ip} = 1;
> $date_cnt++;
> }
> $hold_date = $date;
> }
>
> foreach $ip (sort keys %day_array) {
> $ip_day_cnt++;}
>
> $tot_ip_cnt += $ip_day_cnt;
> $ext_line[$line] = "<b><i>" . $hold_date . "</b></i> has <b><i>" .
> $ip_day_cnt . "</b></i> unique External IPs.<p>";
>
> # print OPAC_IP @Names;
> close (OPAC_IP);
>
> foreach $ip (sort keys %letters) {
> $ip_cnt++;
>
> }
>
> #print "<p>$ip_cnt";
> # Set length of array to variable
> $countint = @firstip;
>
> # Tally distinctive ips
> foreach $ips(@firstip) {
> $count{$ips}++;
> }
>
> foreach $ips(sort(keys %count)) {
> for ($i = 0; $i <= $countip; $i++) {
> if ($ips == $staionip[$i]) {
> $opacline[$totalcnt] = "The Station <b><i>".$stationname[$i]."</i></
> b> with IP <b><i>".$ips. "</i></b> has visited Opac <b><i>".
> $count{$ips}."</i></b> times.\n";
> $totalcnt++;
> if ( $count{$ips} > $ip_hold) {
> $ip_hold = $count{$ips};
> $station_name = $i;
> }
> }
>
> }
> }
> close(OPAC);
>
> if ($countint == 0) { $totalcnt = 0;}
>
> if ($dayflag eq "yes") {
> $totalline = "There are <b><i> " . $totalcnt . "</i></b> total
> patron stations used for <b><i>" . $monthfind . " " . $daym . "</i></
> b>.";
> } else {
> $totalline = "There are <b><i> " . $totalcnt . "</i></b> total
> patron stations used for the Month of <b><i>" . $monthnow . "</i></
> b>.";
> }
> print OPAC_WEB hr();
> print OPAC_WEB p("There are <b><i>" . $countint . "</i></b>
> internal IP address hits.");
> print OPAC_WEB p("There are <b><i>" . $ext_ip . "</i></b> external
> IP address hits.");
> # print p("There are <b><i>" . ($countout-$countin) . "</i></b>
> external IP address hits.");
> print OPAC_WEB p("There are <b><i>" . $countout . "</i></b> total
> IP address hits.");
> print OPAC_WEB p($totalline);
> print OPAC_WEB p("The Station <b><i>".
> $stationname[$station_name]."</i></b> has the greatest number of hits
> of <b><i>".$ip_hold."</i></b> times.");
> print OPAC_WEB p("There are <b><i>" . $tot_ip_cnt . "</i></b> Total
> unique External IP hits for All Days in <b><i>$monthnow</i></b>.");
> print OPAC_WEB p("There are <b><i>" . $ip_cnt . "</i></b> unique
> External IP hits for the Month of <b><i>$monthnow</i></b>.");
> print OPAC_WEB "<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">";
> print OPAC_WEB "<A NAME=\"int\">Internal<\/A><\/font>";
> print OPAC_WEB "<A HREF=\"\#ext\">External Hits<\/a> ";
> print OPAC_WEB hr();
>
> for ($i = 0; $i <= $totalcnt; $i++) {
> print OPAC_WEB p($opacline[$i]);
> }
> print OPAC_WEB hr();
> print OPAC_WEB "<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">";
> print OPAC_WEB "<A NAME=\"ext\">External<\/A><\/font>";
> print OPAC_WEB "<A HREF=\"\#int\">Internal Hits<\/a>";
> print OPAC_WEB p(@ext_line);
> print OPAC_WEB hr();
> print OPAC_WEB "</center>";


6) You need to learn the different quoting methods so you can avoid
the "leaning tower syndrom".
If you don't need variable interpolation, then use single quotes
instead of double quotes.
e.g., print OPAC_WEB '<A NAME="ext">External</A></font>';

>
> use CGI; print redirect("$opac_month");


7) Why are you tring to load the CGI module for a second time?

The redirect is probably why you're getting a blank page. From
what I can tell, you're only passing the filename. When doing a
redirect, you need to specify the full url, which includes the
protocal.

http://search.cpan.org/~lds/CGI.pm-3...RECTION_HEADER

>
> } else {
>
> ################################################## ########################
> # If a file name has not been given, process the file, create webpage
> to
> # ask for it
> #
> print header, start_html("Monthly WebOpac"), h1("Monthly WebOpac
> Report");
>
> print hr();
> print start_form();
> print p("Day File: ",textfield("dayopac"), "<b> * form should be
> WebOpac_(<i>3-letter Month</i></b>)");
> # print p("Check Test: ",checkbox("opaccheck"));
>
> print p(submit("Submit Entry"));
> print end_form(), hr();
>
> }
>
> print end_html;</code>



 
Reply With Quote
 
Ron Bergin
Guest
Posts: n/a
 
      10-10-2007
I skipped over another important issue, so here it is.

On Oct 9, 8:23 pm, Ron Bergin <r...@i.frys.com> wrote:
> John and Mumia have pointed out most of the problems, but here are
> some more.
>
> On Oct 8, 4:10 pm, Joe <jruff...@gailborden.info> wrote:
>
> > Here is my code, I picked one of my shorter scripts:

>

[snip a bunch]

> > print OPAC_WEB hr();
> > print OPAC_WEB "<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">";
> > print OPAC_WEB "<A NAME=\"ext\">External<\/A><\/font>";
> > print OPAC_WEB "<A HREF=\"\#int\">Internal Hits<\/a>";
> > print OPAC_WEB p(@ext_line);
> > print OPAC_WEB hr();
> > print OPAC_WEB "</center>";

>

[snip some more]
>
> > use CGI; print redirect("$opac_month");

>

You're not printing the closing body or html tags.

> > } else {

>
> > ################################################## ########################
> > # If a file name has not been given, process the file, create webpage
> > to
> > # ask for it
> > #
> > print header, start_html("Monthly WebOpac"), h1("Monthly WebOpac
> > Report");

>
> > print hr();
> > print start_form();
> > print p("Day File: ",textfield("dayopac"), "<b> * form should be
> > WebOpac_(<i>3-letter Month</i></b>)");
> > # print p("Check Test: ",checkbox("opaccheck"));

>
> > print p(submit("Submit Entry"));
> > print end_form(), hr();

>
> > }

>
> > print end_html;</code>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ calling perl script - Not able to get the stack arguments pushedrom XPUSH in perl script Yogi Perl Misc 1 09-13-2012 11:30 AM
Not able to display color in excel not able to display color in excel using xml sed_y XML 0 02-15-2012 09:46 PM
Server Not able to read messages of length>256 bytes in a typicalClient Server Scenario Ravikanth C Programming 3 11-28-2008 06:45 PM
Not able to see ASP.NET web form control in IE 6.0 of 2003 Server =?Utf-8?B?R2hhbmFzaHlhbQ==?= ASP .Net 0 03-15-2006 07:17 AM
The same script work fine with NT, doesn't work 2003 rigo ASP General 0 04-15-2005 02:31 PM



Advertisments