loop362 has asked for the wisdom of the Perl Monks concerning the following question:

Aloha,

Something really strange.....
I am still rather new to perl and cgi. I have been developing a script and testing it for a couple a weeks now and made some progress.

What has surprised me is that when I click on submit now the browser asks me what I want to do with the file. I would think that means the browser doesn't recognize the .cgi extention. The other form on the page reacts normally processing its script. I have checked both action lines on the forms.I checked line ending for Unix and permissions. I'm using Adobe GoLive and BBEdit. Ran it in Terminal and got this error.
Undefined subroutine &main::pram called at ./Write.cgi line 15

Line 15 is still declaring variables! Am I missing something really simple? Mahalo, JWG

Replies are listed 'Best First'.
Re: CGI wants to save file?
by davido (Cardinal) on Jun 18, 2005 at 05:45 UTC

    It's probably a configuration issue with your webserver, or incorrect placement of the script within your server's filestructure. If the server is properly configured, and the script is where it belongs, or otherwise identified as a CGI script such that your webserver knows what to do with it, there should be no way for any sort of browser (mis)configuration to ever see the actual code behind the CGI script.

    It's the web server's responsibility to execute a CGI script. If it's failing to do so, it's not the browser's fault. Somehow you're not identifying to your webserver that the CGI script is a CGI script. Instead, it's thinking it is just some file, and handing it un-executed to the browser. The browser reacts by asking if you want to save this file.

    The second issue is that of your error message when you run it from the command line:

    Undefined subroutine &main::pram called at ./Write.cgi line 15

    Unless your script defines a subroutine named pram(), my guess is that you really mean to be calling param() on line 15 of your script named Write.cgi.


    Dave

      Aloha,

      At least I now have a place to start troubleshooting. I guess I was getting a little too comfortable. I appreciate your advice.

      Mahalo, JWG
Re: CGI wants to save file?
by Adrade (Pilgrim) on Jun 18, 2005 at 07:50 UTC
    I'd also check to make sure your script is sending the correct content-type - a small spelling mistake could cause your browser to display that dialog.

    What's strange is that your browser should be giving you a 500 error if the script won't run in the terminal. Throw in use CGI::Carp qw(fatalsToBrowser); at the top of your script and see what you get in your web broswer when you try to run your script.

    Best of luck,
      -Adam

    --
    Impossible! The Remonster can only be killed by stabbing him in the heart with the ancient bone saber of Zumakalis!

      Aloha

      Absolutely correct in reccomending use CGI::Carp qw(fatalsToBrowser);
      It was a really small spelling mistake. The CGI::Carp gave better info than running the script in Terminal.

      Mahalo JWG