Newbie needs help 
Author Message
 Newbie needs help

I am attempting to create a counter which is not seen on the page.  Here
is the code for the script:

#!/usr/local/bin/perl
print "Content-type:text/html\n\n";
$countfile="dm2k_counter.txt";
open(INF, "$countfile");
$begincount=<INF>;
close(INF);
$newcount = $begincount + 1;
open(OUTF, ">$countfile");
print OUTF "$newcount\n";
close(OUTF);
open (INF, "$countfile");
$newcount=<INF>;
close (INF);
echo;
open (OUTF2,">dm2k_counter.html");
print OUTF2 "<html>\n";
print OUTF2 "<head>\n";
print OUTF2 "<title>DM2K Visit Log</title>\n";
print OUTF2 "</head>\n";
print OUTF2 "<body>\n";
print OUTF2 "Since April 1, 1999, there have been $newcount visitors\n";

print OUTF2 "</body>\n";
print OUTF2 "</html>";
close (OUTF2);
exit;

The file works if I run it at the command line (Solaris), but when I
attempt to run it from a web browser, it does not work.  Does anyone
have any insight?  Thank you very much.

-Marek



Sat, 27 Oct 2001 03:00:00 GMT  
 Newbie needs help
A simple question:
is the file containing the 'counter' reachable from the path you use when
your server execute the script( cgi-bin directory ?).
To test it, add a "|| die 'cant open file';"   atfer your open file command.

Just to test..



Sun, 28 Oct 2001 03:00:00 GMT  
 Newbie needs help


Quote:
> A simple question:
> is the file containing the 'counter' reachable from the path you use when
> your server execute the script( cgi-bin directory ?).
> To test it, add a "|| die 'cant open file';"   atfer your open file command.

> Just to test..

You forgot to include $! in the error message.  And if you don't have
access to the server logs (many of us don't, believe it or not!), send
the message to the browser via STDOUT, not to God-knows-where via
STDERR.

   open FILE, $file or do { print "Content-type: text/plain\n\n",
         "Can't open '$file'. $!\n"; exit }

Not 'Just to test..." -- all the time!

--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/



Sun, 28 Oct 2001 03:00:00 GMT  
 Newbie needs help
: You forgot to include $! in the error message.  And if you don't have
: access to the server logs (many of us don't, believe it or not!), send
: the message to the browser via STDOUT, not to God-knows-where via
: STDERR.

:    open FILE, $file or do { print "Content-type: text/plain\n\n",
:          "Can't open '$file'. $!\n"; exit }

Hardly necessary if you

use CGI::Carp qw(fatalsToBrowser);



Mon, 29 Oct 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Newbie needs help...

2. Newbie needs help debugging code called from perl script

3. Newbie needs help

4. Newbie needs help ...

5. NEWBIE - Need help with perl/viewing

6. Newbie need help with strings

7. Newbie Needs Help: Whitespaces

8. NEWBIE needs help with NNTP

9. ----> Complete Perl Newbie needs help compilin

10. Newbie needs help to write a Perl script.

11. Newbie needs help with utime

12. newbie needs help please

 

 
Powered by phpBB® Forum Software