PDA

View Full Version : cgi script spontaneously stopped working?


LeafWind
03-22-1999, 08:31 PM
A cgi script I thought I had working just fine, now doesn't work any more, and I can't figure out why. I don't know how long it hasn't been working, I last checked on it a bit more than week ago or so (and all seemed well), and last night is when I discovered the problem.

I call it the way I used to call it:
http://leafwind.com/cgi-bin/urlsubmitter/urlsubmitter30.cgi
and now I get an error I never saw before:

Software error:
Execution of urlsubmitter30.cgi aborted due to compilation errors.


Umm . . . ? I checked the "script" file in my logs_cgi directory, but nothing new there. I have this line at the top of my script, as suggested by Del for another problem (which got solved):
use CGI::Carp qw(fatalsToBrowser);
which was supposed to make it send more info to the browser to help me figure out what happened when it didn't work, but the only error message I get is the one quoted above.

I have re-uploaded all the files to make sure they're ascii and not binary, and I have checked all the permissions to make sure they're set at 755 (although I'm pretty sure nothing got touched from this end since it was working for me).

Now what?

Any suggestions you could give about how to figure out the problem would be greatly appreciated.

Thanks.

Bekariso, baffled.

PS. other scripts I have in my cgi-bin all appear unaffected, it's just this one.

------------------
www.LeafWind.com (http://www.LeafWind.com)
Growing web sites that thrive in the winds of change.

Stephen
03-22-1999, 11:34 PM
I'll bet you anything it's exactly what it appears to be--a compilation error. You probably made a minor change somewhere in the source code and then forgot to check that it runs locally before uploading. Run it at the command line:

perl urlsubmitter30.cgi

If it doesn't produce an error with a line number then I take it all back...

Terra
03-23-1999, 12:02 AM
The canonical way to test scripts at the command line is:

$perl -c scriptname.pl

To really run it through it's paces:

$perl -cw scriptname.pl

I wouldn't recommend to run the script blindly, as it *might* write to a file that is dependent upon the input via CGI methods... I've seen this sloppy coding way more than once... http://www.aota.net/ubb/wink.gif

--
Terra
sysAdmin
FutureQuest

LeafWind
03-23-1999, 01:17 PM
Thanks for the ideas.

I got the script at fbwwo.hypermart.net (http://fbwwo.hypermart.net) if you want to see -- though I've had to re-do a lot of it: the english grammer was pretty bad, the html output really primative, and some of the urls included were outdated. It was a great learning experience for me, to figure out how to fix all that, though -- and I was sure I had checked it all out once I had it fixed and made sure it all worked . .. hmph.

I was especially confused because while getting it to work, I got a variety of 500 type errors in my browser, but never this "software error" one.

Terra, I'm a bit confused, are you saying I should or shouldn't test that script using the commands you suggested? I''ve never actually used telnet before, so I don't want to do anything wrong stumbling around with it!

Thanks,

Bekariso

Rich
03-23-1999, 06:34 PM
I have noticed that the .cgi that I downloaded has the same content as when the .cgi is executed (see my previous post). I must conclude from this that a browser's right-click, Save Target As... function does something that I guess I never realized before. It executes the file and downloads the results rather than downloading the contents of the file.

Rich

Justin
03-23-1999, 07:05 PM
You are right. Anything marked by the server as executable (ie, anything in the cgi-bin) executes when called. The server will not serve the script's code.

When a browser requests a document, it is, in fact, downloading it. Whether it be an HTML page, GIF image, ZIP file, whatever, it is downloaded. The browser then decides what to do with it.

If it's an HTML page, it renders the page for you to view. If it's a GIF, it displays it. If it's unknown, it will prompt you to download it.

When you right-click --> Save Target As, the only thing that does is tells the browser that you do not want to display the file, you just want to save it to disk. As far as the server is concerned, you still requested the file to be sent to you, and it handles it in the same way.

This also protects from being able to view the source of people's cgi's, PHP pages, SSI's, etc. Notice that when you download a SHTML page, you don't see the SSI tags - just the HTML that is sent.

Well, my power is flickering so I better post this right now before....


------------------
Justin Nelson
FutureQuest Tech Support

Rich
03-24-1999, 12:31 AM
I'm sure I'm gonna have a big DOH from this question, but does anyone know HOW this script works? I can't read leafwind's cgi-bin, but I found a copy of urlsubmitter30.cgi at the following location:

http://www.aristo.cc/url/

If you download the file and view it, it is a simple html document with a form in it. The form action calls itself, i.e. urlsubmitter30.cgi. There is no scripting or other code anywhere in the document.

In addition, the script calls itself to produce a banner and calls itself near the bottom to produce a counter. Really neat trick.

So, now the dumb question: How can an html file without any code call itself and produce these results?

Rich

Rich
03-24-1999, 08:01 PM
Thanks Justin! When I was viewing the Indexes page of files (er, links) in the directory, my mind short-circuited and thought this was somehow like a list produced with the ftp:// protocol. Silly me.

Rich
Doh Doh

LeafWind
03-25-1999, 03:21 PM
Hey everyone . . .

I'm still a bit confused as to what to do with the script. Can someone please clarify how I should test it? ie. are you saying I should or shouldn't use the telnet commands suggested, and in what order should I try them? (I have not used telnet for cgi script de-bugging before and don't want to create more problems with it).

Thanks!

Bekariso

Terra
03-25-1999, 05:09 PM
You can use either of the 2 above commands without fear of execution... They merely do a compilation syntax check of the script, and will catch about 85% of all errors... The rest are flawed logic and/or runtime errors...

Running the script blindly would be:
perl urlsubmitter31.cgi
or
./urlsubmitter31.cgi

Hope this makes sense...

--
Terra
sysAdmin
FutureQuest