http://www.perlmonks.org?node_id=1017873


in reply to CGI question

I can run scripts from one book but I can't from the other book.

That should be pretty easy to troubleshoot. What are the differences in the html between the two books? Specifically, you should examine the form's action attribute in the html. Any differences in the paths listed there? Can you use one book's html with the other book's working perl script?

What are the differences in the perl scripts between the two books? Do both books use script names that have the same extension: .cgi v. .pl? Your server may look at a file's extension to decide whether a file is a perl script and should be executed or whether the file should be returned as text.

What server are you using?

Did you make both your perl scripts executable? $ chmod a+x prog.pl

You might need this shebang line:

#!/usr/local/env perl

When you are testing any cgi script, you should send errors to the browser by adding this line:

use CGI::Carp qw(fatalsToBrowser);

Otherwise, your perl script will fail silently, and you will have to check your server's logs to discover the error.

What does your server's log file say? Find out where it is located, and look at the last 20 lines or so.

You should always post what error you got, or if you didn't get an error, you should state what you expected to happen, and what actually happened. Do not say, "My program doesn't work. Help!"

Replies are listed 'Best First'.
Re^2: CGI question
by MidLifeXis (Monsignor) on Feb 08, 2013 at 18:51 UTC

    As a note to the grandparent node, a little bit of emphasis on what 7stud said:

    When you are testing any cgi script, you should send errors to the browser by adding this line: (emphasis added)
    Just make sure it does not go into production with errors to the browser :-)

    --MidLifeXis

Re^2: CGI question
by Anonymous Monk on Feb 08, 2013 at 19:29 UTC

    O.K. I'm on it. No sleep till Brooklyn