Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie question 1

Status
Not open for further replies.

reb37

Programmer
Apr 3, 2001
10
US
"Hi, this is kind of an embarassing question. I'm using the "learn cgi in 24hours" book to get started with some basic cgi scripting. The book recommends using apache as a test environment, which I've downloaded and installed. According to the book, the server is working correctly b/c I get their welcome message when I type in localhost. However, the test script isn't working, either in the browser or from the command line to test it. I think the reason is that I'm not sure how to put in the first line indicating where perl resides on my pc. Do I say c:/perl/bin? or what??? Everybody says use #!/usr/local/bin/perl but that isn't working for me b/c that's not where perl is. HELP! I know this is really basic but I'd really appreciate your help. I'm using ActiveState Active Perl, Apache 1.3.19(win32) and Win2000pro on a ThinkPad. The error message I get in the browser is "the page cannot be displayed." In dos I get "no such file or directory for the command c:\perl\bin\perl.exe c:\apache\cgi-bin\test.cgi.
 
try
#!/perl
if perl.exe is in c:\perl, or if perl.exe is in c:\perl\bin use
#!/perl/bin
in other words, if you ahve c:\path\to\perl.exe, use
#!/path/to
in your script.

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Hi,
Unfortunately that didn't work. Is there something I'm supposed to be doing with the apache server to set it up? There doesn't seem to be any kind of console or anything that I can do with it. My book doesn't say anything either.

Thanks!
 
Well, with apache you have to enable mod perl support, and enable cgi execute permissions in the directory where the script is. These are generally turned off by default. Read through the config file and see if you can turn some of them on..

Does your program run from the command line now?

Post the error messages you get from teh command line/

Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.
 
Hi,

The error msg. I get from the command line is "can't open perl script c:\apache\cgi-bin\test.cgi. No such file or directory." But when I go to the apache directory in dos the file is there. Also, I'm not sure I didn't mess up the config file b/c I set it to open in Word. Is that okay? I really don't know what I'm looking for in terms of editing something (see, it really is a newbie question:))

Thanks for all your help so far.
 
Hi,

You shouldn't have to change anything in the Apache configuration files and your script should execute fine if you put it in the cgi-bin assuming there are no problems with the script and you have the plinger line correct.

The first line should look like this (if perl.exe is in c:\perl\bin):

#!c:/perl/bin/perl.exe

Mine looks like this:

#!d:/programs/development/perl/bin/perl.exe

Make sure you specify the .exe and include the plinger (!).

Check the script has no errors in it by typing:

perl -c script.pl (or whatever you called it)

If you get a Syntax OK copy the script to the CGI-BIN in the Apache directory and try and access it through
Also make sure you set the Content-type before you try doing any print statements or you'll get a 500 Internal Server Error. To set the content type simply put:

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

Before any of your other print statements. This should be covered in the book.

Hope this helps!

Tim
 
As long as you saved the config file as text/only after editing it in Word then that's fine. As a rule, try and edit config files with WordPad, NotePad or something like Programmers File Editor (
Cheers,

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top