User Control Panel
Advertisements

HELP US, HELP YOU!

A simple perl counter with problems
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions
View unanswered posts
Author Message
JTW
God Like
God Like


Joined: 07 Mar 2004
Posts: 579
Location: Maidstone
Reputation: 67.1
votes: 4

PostPosted: Wed Apr 20, 2005 1:54 pm    Post subject: Reply with quote

Hey everyone,
I am making a new site, so I thought that i would try to make all the additional little features by hand (counter and feedback etc) But when I started making the feed back i get this error
Quote:
[Wed Apr 20 14:56:10 2005] [error] [client 218.167.48.218] Premature end of script headers: /home2/jttesne/public_html/cgi-bin/count.pl
And i also get
Quote:
[Wed Apr 20 15:01:03 2005] [error] [client 218.167.48.218] script not found or unable to stat: /home2/jttesne/public_html/cgi-bin/count.pl


The code is like this
Code:
#!/usr/bin/perl -wT<br /><br />my $count;<br />open (COUNT, 'count.txt'); <br /><br />#load the lines into a array <br />$count = <COUNT>;<br />$count += 1;<br />print JOKE "$count";<br />#close the file <br />close (COUNT); <br /><br /><br />print "Content-type: text/html\n\n";<br />print "$count";<br />

It has been CHMODed to 755
Thanks in advance for any help

_________________
"Help us, Help you" - BotDepot
Back to top
mat007
Almost An Agent
Almost An Agent


Joined: 12 Jan 2004
Posts: 1375

Reputation: 15.8Reputation: 15.8
votes: 2

PostPosted: Wed Apr 20, 2005 3:03 pm    Post subject: Reply with quote

Try returning 1

Code:
1;
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Wed Apr 20, 2005 5:22 pm    Post subject: Reply with quote

Scripts don't need to return 1.

JTW, I think your problem has to do with pring JOKE $count; - you don't have an open file handle called JOKE. Did you mean COUNT? If so, then you're going to have to open that file so that you can append to it. In addition, you should check for failure on opening the file:

Code:
open( FILE, "count.txt") || &errorDie;


Where errorDie is a function that prints content type, the error message and then exits the script.
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Wed Apr 20, 2005 6:26 pm    Post subject: Reply with quote

CGI::Carp is a useful module to have around, too.

Just stick:
Code:
use CGI::Carp qw(fatalsToBrowser);


And it will print out fatal errors to your browser (just like it would in a DOS window). Useful for catching stuff easily without having to check your error log.

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
zander
God Like
God Like


Joined: 14 Jan 2004
Posts: 540
Location: england
Reputation: 66.6

PostPosted: Fri Apr 22, 2005 12:21 pm    Post subject: Reply with quote

or u could just do it in php?
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Fri Apr 22, 2005 1:16 pm    Post subject: Reply with quote

Funny how Mojave was the only one to notice the glaring error he had there. For all the know it all attitudes, you guys sure don't pay attention.
_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Fri Apr 22, 2005 6:39 pm    Post subject: Reply with quote

QUOTE(alienz @ Apr 22 2005, 09:16 AM)
Funny how Mojave was the only one to notice the glaring error he had there. For all the know it all attitudes, you guys sure don't pay attention.
[right][snapback]47929[/snapback][/right]


Mojave was the second one to reply. So the only one who didn't pay attention would be Mat007. So if Mat007 is also a know-it-all, then your statement is only true for the one person. If he's not a know-it-all, your statement's not true for anybody. Not in this post anyway. There was only one example of ignorance before Mojave saw that error.

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Fri Apr 22, 2005 6:47 pm    Post subject: Reply with quote

hahahahah Like YOU dont act like one too.
_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Fri Apr 22, 2005 7:35 pm    Post subject: Reply with quote

QUOTE(alienz @ Apr 22 2005, 02:47 PM)
hahahahah Like YOU dont act like one too.
[right][snapback]47936[/snapback][/right]


My reply didn't say anything about me claiming I don't think I'm a know-it-all. It's just that your post wasn't necessary, you should wait for the topic where 10 people reply with dumb answers and then you'd be fully justified in yelling at us. Why are you such a jerk lately?

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Fri Apr 22, 2005 9:55 pm    Post subject: Reply with quote

Okay...JT, your calling JOKE unstead of COUNT.

Anyway, I coded my own, It's a little different and works.

Code:
#!/usr/bin/perl<br /><br />## Simple hit counter. :)<br />## By Ian Gutjahr.<br /><br />use Data::Dumper;<br />my $counter = do("./hits.dat");<br />sub Save<br />{<br />        open SAVE, "> ./hits.dat";<br />        print SAVE Dumper($counter);<br />        close(SAVE);<br />        my $counter = do("./hits.dat");<br />}<br />   $counter->{Hits}++; Save;<br />   print "Content-type: text/html\n\n";<br />   print "<b>There has been ".$counter->{Hits}." to this page!</b>\n\n";
Back to top
JTW
God Like
God Like


Joined: 07 Mar 2004
Posts: 579
Location: Maidstone
Reputation: 67.1
votes: 4

PostPosted: Sat Apr 23, 2005 12:21 am    Post subject: Reply with quote

Thanks TCS I think il use yours, As it looks more like it will work than mine Razz
_________________
"Help us, Help you" - BotDepot
Back to top
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Sat Apr 23, 2005 1:25 am    Post subject: Reply with quote

It does work Razz

http://networked-hosting.net/perl/hit_counter.pl
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Mon Apr 25, 2005 11:43 am    Post subject: Reply with quote

QUOTE(Guest @ Apr 25 2005, 05:40 AM)
Little grammar mistake there Ian Razz

Quote:
   print "There has been ".$counter->{Hits}." to this page!\n\n";


Prints
Quote:
There has been 21 to this page!


Doesn't quite make sense Smile

Quote:
   print "There has been ".$counter->{Hits}." hits to this page!\n\n";


It pays to do it right Wink
[right][snapback]48004[/snapback][/right]


Maybe even
Quote:
print "There have been ".$counter->{Hits}." hits to this page!\n\n";


Razz

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Mon Apr 25, 2005 4:38 pm    Post subject: Reply with quote

Now that was useful...
_________________
~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Back to top
mattaustin
Sentinel
Sentinel


Joined: 19 Jul 2004
Posts: 556
Location: Los Angeles, CA
Reputation: 50.7
votes: 1

PostPosted: Mon Apr 25, 2005 4:41 pm    Post subject: Reply with quote

if there were only one hit..... yours would still be "bad grammar" cer
_________________
[ matt ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group