in reply to Re: First Script
in thread First Script

Mick, did you run the code yourself (if so, could you explain how) or did you run it off my website? Thanks

Replies are listed 'Best First'.
(Ovid) RE: RE: Re: First Script
by Ovid (Cardinal) on Jul 18, 2000 at 01:11 UTC
    Well, if you are able, run the script from the command line. If your program fails to compile, that may be the problem.

    Quick checklist:

    • Correct permissions.
    • Correct shebang line
    • In the correct directory?
    • Is a particular extension required (i.e., do you have myprog.pl instead of myprog.cgi)?
    Another thing to do (in test only, don't use this for production), is to add the following line to the script:
    use CGI::Carp qw(fatalsToBrowser);
    If your script actually gets as far as compiling and the program tries to run, this will output the error messages to your browser, which aids debugging. Make sure that you take this out when you move the code to production as there is no sense in giving hackers additional information.

    From what you are describing, it sounds like the problem is not with your code, but with the configuration. You have your code in the wrong place or something.

    Is there any chance that you made corrections to your code that you forgot to upload to the server?

      Ovid, when I added the line

      use CGI::Carp qw(fatalsToBrowser);

      I got an error:
      Software error:
      Can't locate object method "new" via package "CGI" at .......
      So I presume that the program is compiling. And when I run it from the command line it's all good. Thanks a lot for helping a very bad perl programmer.

        Oh! This is a good sign. It means that your script is trying to run.

        Perhaps I should have been more clear. use CGI::Carp qw(fatalsToBrowser); does not replace use CGI;. I suspect that either you used it in place of use CGI; or you are trying to assign new CGI before the use CGI; statement. Either of those will produce the error you describe. Try the following:

        #!/usr/bin/perl -Tw use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); my $query = new CGI; # the rest of your code goes here.
        Note that use CGI; is before the new CGI; assignment.

        Also notice the -T switch on the command line. That's for "taint checking." You're going to hate this, but you really need to read perlsec and understand what's going on. If you start learning this early, you will save yourself a lot of problems down the road.

        Cheers,
        Ovid

        P.S.: Don't think of yourself as a bad Perl programmer, think of yourself as a new Perl programmer. There's a difference :)

RE: RE: Re: First Script
by mrmick (Curate) on Jul 18, 2000 at 02:43 UTC
    I ran it (without any modifications) on my intranet webserver. It's an HP-UX running Netscape Suitespot server, if that helps. :-)

    Mick