my simple perl application didn't work 
Author Message
 my simple perl application didn't work

I'm new to PERL and I've install the ActivePerl in my PC, then i still can't
run my simple cgi in my PC.
Then i post this problem to Newsgroup, what i get is they suggest me to get
Apache installed in my PC.

So, I've download it, and I'd install it.
I think i've install it successfully because when i key in this
http://www.*-*-*.com/ ,
it display a page that say if i can read that page, it mean that i've
successfully install it(Apache Server).

Now i'm going to test my CGI progam(a simple counter only), but it still not
working.
I don't know what's the problem and where is it happen.

The following is my files info:
location of my cgi(the counter)         D:\My Documents\HTML\Home
Page\walink\walink_page\hitcounter.cgi
location of my testpage.html            D:\My Documents\HTML\Home
Page\walink\walink_page\testpage.html
my ActivePerl installed at                C:\Perl\
my Perl compiler(perl.exe)               C:\Perl\bin\perl.exe

My perl program:
#!C:\Perl\bin\perl.exe

#texthitcounter.cgi
#By Dora Chow
#
#simple hit counter

$datafile="counter.dat";        # data file that contains current visitors

($fsec,$fmin,$fhour,$fday,$fmon,$fyear,$fwday,$fyday,$fisdst) =
localtime(time);

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

open(COUNTER, $datafile);
 $count=<COUNTER>;
close COUNTER;
$count++;

open(COUNTER, ">$datafile");
 print COUNTER $count;
close COUNTER;

print "$count";
exit;

Note: this perl program work when I double click on it, it will print out
the number

My testpage code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head><title>testpage</title></head>
<body>
<!--#include virtual="hitcounter.cgi"-->
</body>
</html>

If you need further info of my files in my PC, do tell me.
Thanks for helping.

Regard,
Peter



Thu, 12 Jun 2003 15:49:06 GMT  
 my simple perl application didn't work


Quote:
> I'm new to PERL and I've install the ActivePerl in my PC, then i still
can't
> run my simple cgi in my PC.
> Then i post this problem to Newsgroup, what i get is they suggest me to
get
> Apache installed in my PC.

> So, I've download it, and I'd install it.
> I think i've install it successfully because when i key in this
> http://127.0.0.1/ at the address of my browser and enter,
> it display a page that say if i can read that page, it mean that i've
> successfully install it(Apache Server).

> Now i'm going to test my CGI progam(a simple counter only), but it still
not
> working.
> I don't know what's the problem and where is it happen.

> The following is my files info:
> location of my cgi(the counter)         D:\My Documents\HTML\Home
> Page\walink\walink_page\hitcounter.cgi
> location of my testpage.html            D:\My Documents\HTML\Home
> Page\walink\walink_page\testpage.html
> my ActivePerl installed at                C:\Perl\
> my Perl compiler(perl.exe)               C:\Perl\bin\perl.exe

> My perl program:
> #!C:\Perl\bin\perl.exe

> #texthitcounter.cgi
> #By Dora Chow
> #
> #simple hit counter

> $datafile="counter.dat";        # data file that contains current visitors

> ($fsec,$fmin,$fhour,$fday,$fmon,$fyear,$fwday,$fyday,$fisdst) =
> localtime(time);

> print "Content-type: text/html\n";
> print "Pragma: no-cache\n\n";

> open(COUNTER, $datafile);
>  $count=<COUNTER>;
> close COUNTER;
> $count++;

> open(COUNTER, ">$datafile");
>  print COUNTER $count;
> close COUNTER;

> print "$count";
> exit;

> Note: this perl program work when I double click on it, it will print out
> the number

> My testpage code:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

> <html>
> <head><title>testpage</title></head>
> <body>
> <!--#include virtual="hitcounter.cgi"-->
> </body>
> </html>

> If you need further info of my files in my PC, do tell me.
> Thanks for helping.

> Regard,
> Peter

You probably do not have Apache configured properly.
In the apache 'conf' directory you will find http.conf.
You willl need to put two lines in to get things working.
First you need to get Apache to use perl to handle cgi scripts so where your
add handler lines are add another add handler line.
AddHandler cgi-script .pl
then you need to add a directory permission to allow cgi execution in the
directory.
So you need some lines like
<Directory "c:/htdocs/cgi-bin">
    AllowOverride None
    Options All
</Directory>
the path is of course meant to be the path to your scripts.
Hope that helps.


Thu, 12 Jun 2003 17:00:36 GMT  
 my simple perl application didn't work

Quote:

> Subject: my simple perl application didn't work

              ^^^^^^      ^^^^^^^^^^^

A simple Perl application would be to get your program
working from the _command line_ first.

Using Perl in a CGI environment is more difficult. Get the easy
part working first.

Can you run Perl programs from the command line?

If so, then you do not have a Perl problem!

Quote:
>I'm new to PERL and I've install the ActivePerl in my PC, then i still can't

            ^^^^

It is "Perl" or "perl", not "PERL".

Quote:
>run my simple cgi in my PC.
>Then i post this problem to Newsgroup, what i get is they suggest me to get
>Apache installed in my PC.

Installation of web servers does not have anything to do with
Perl, and is off-topic in a Perl newsgroup.

There are other newsgroups for discussing web stuff:

      comp.infosystems.www.authoring.cgi
      comp.infosystems.www.servers.mac
      comp.infosystems.www.servers.misc
      comp.infosystems.www.servers.ms-windows
      comp.infosystems.www.servers.unix

Quote:
>So, I've download it, and I'd install it.
>I think i've install it successfully because when i key in this
>http://127.0.0.1/ at the address of my browser and enter,
>it display a page that say if i can read that page, it mean that i've
>successfully install it(Apache Server).

After you install it, the next step would be to configure it
to run CGI programs.

Quote:
>I don't know what's the problem and where is it happen.

You haven't gotten the server configured correctly yet.

Quote:
>My perl program:
>print "Content-type: text/html\n";

Your program does not output HTML. You should not lie to the
browser like that. If you say you are going to give it HTML,
then you should give it HTML. If you are going to give it
plain text, then you should say that you are going to give
it plain text.

Quote:
>open(COUNTER, $datafile);

You should always, yes *always*, check the return value from open():

   open(COUNTER, $datafile) || die "could not open '$datafile'  $!";

[ snip code that runs in a multitasking environment, but does not
  do any file locking.
]

After you get your server-config issues fixed, you have yet
more problems to deal with.

You should probably look at the Perl FAQ, part 5:

   "I still don't get locking.  
    I just want to increment the number in the file.  
    How can I do this?"

Quote:
>Note: this perl program work when I double click on it, it will print out
>the number

Ah hah! So you do have it running outside of a CGI environment.
That makes it off-topic here. Ask in a newsgroup that cares
about the CGI environment.

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Thu, 12 Jun 2003 19:42:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. warnings under perl 5.004_01 that my script didn't give in perl 5.003

2. can't get simple reference working!

3. simple script doesn't work?!!

4. So simple, but it won't work..

5. Need help with simple code not working on my ISP's server

6. Simple, should work, doesn't :-(

7. Why won't this simple script work??

8. Simple Script won't work

9. Can't get a simple GETHOSTBYADDR() to work

10. Simple/small socket script doesn't work

11. Why doesn't this simple script work?

12. My simple mpg123 front-end won't work

 

 
Powered by phpBB® Forum Software