LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-05-2003, 07:21 PM   #1
HappyDude
Member
 
Registered: Jul 2003
Posts: 140

Rep: Reputation: 15
Question Unknown error. Any help?


Ok I'm having a really annoying error. When I run the program on Windows with Perl 5.8.0 it works fine. However when I run it on RH8 with Perl 5.8.1 it doesnt. I've added the -W switch to the script but all that appears in the logfile is "Premature end of script headers: print.pl". Does that help? No. Can you help? Please? (And if you're wondring about the "This is to make Apache happy" parts they are there so Apache doesnt flood the logs with "MainDST::blah is used once".)
Code:
#!/usr/bin/perl -W

print "Content-type: text/html\n\n";

######################### This is to get the variables.
($Second, $Minute, $Hour, $DayOfMonth, $Month, $Year, $WeekDay, $SecondofYear, $IsDST) = localtime(time);

$IP = $ENV{REMOTE_ADDR};

# This is to make Apache happy.

@lame = ($IsDST, $SecondofYear, $Second);

######################## This section is for time.
$x = $Hour;

if($Hour >= 12)
{
$realhour = $x - 12;

$PMAM = "PM";
} else {
$realhour = $x;
$PMAM = "AM";
}

if($realhour == 0)
{
$realhour = 12;
}

if($Minute <= 9)
{
$zerom = "0";
} else {
$zerom = "";
}


##################### This is for the date.
@monthn = ('January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$months = $Month;
@day = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');

# This is for the year.
$lyear = $Year;

if($lyear >= 100)
{
$alyear = $lyear - 100;
$realyear = $alyear + 2000;
} else {
$realyear = $Year;
}

if($Year <= 99)
{
$zeroy = "19";
} else {
$zeroy = "";
}

# Open the file.

open(IP, '>>ip.txt');

# This part is devoted to logging the IP

if($IP =~ /^(10\.10|192\.168|172\.16)/)
{
print IP "Private ($IP) $realhour:$zerom$Minute $PMAM on $day[$WeekDay] $monthn[$months] $DayOfMonth, $zeroy$realyear\n";
print "IP: Logged <!-- This is to make Apache happy: @lame -->";
} elsif($IP ne "")
{
print IP "$IP $realhour:$zerom$Minute $PMAM on $day[$WeekDay] $monthn[$months] $DayOfMonth, $zeroy$realyear\n";
print "IP: Logged <!-- This is to make Apache happy: @lame -->";
} else {
print IP "Unknown IP at $realhour:$zerom$Minute $PMAM on $day[$WeekDay] $monthn[$months] $DayOfMonth, $zeroy$realyear\n";
print "IP: Unknown Error <!-- This is to make Apache happy: @lame -->";
}

# Close the file.

close(IP);
 
Old 10-05-2003, 09:07 PM   #2
eric.r.turner
Member
 
Registered: Aug 2003
Location: Planet Earth
Distribution: Linux Mint Debian Edition (LMDE)
Posts: 215

Rep: Reputation: 31
Probably completely unrelated to your problem, but shouldn't it be

Code:
#!/usr/bin/perl -w
rather than

Code:
#!/usr/bin/perl -W
???
 
Old 10-05-2003, 09:27 PM   #3
HappyDude
Member
 
Registered: Jul 2003
Posts: 140

Original Poster
Rep: Reputation: 15
-W is different because it (supposedly) reports more errors then -w. I tried them both but get the same result.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] shmget(lowmem) error: Unknown error 999 kaz2100 Linux - Software 1 10-26-2010 04:11 AM
Unknown error fuzzymallets Fedora 8 05-04-2005 09:38 AM
Unknown boolean error mebrelith Fedora 4 01-24-2005 03:47 AM
xmame unknown error madskillz Linux - Games 1 06-12-2004 11:39 AM
compile error: #error unknown processor family kmack2001 Linux - Newbie 0 02-14-2004 11:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration