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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.pl & .cgi difference? problems!! 1

Status
Not open for further replies.

cian

Technical User
Oct 11, 2001
1,383
0
0
Hi guys,

I am having a majour problem, hope you can help.

I have a site hosted with a certain company who are running Linux Red Hat 6.1-7.1 with Perl version 5.00503.
The problem is whenever I try to install a CGI script the script will never work with .cgi extensions, so I have to change all extensions to .pl and in this case about 10% of the scripts will "almost" work!
Can you guess any reason why I need to change extensions to get the scripts to work (almost) and do you think there is any way I can get around this?
I have approx 30 different CGI scripts, currently 4 are working!!! :(

Some of the problems I get include Error 500, the file tries to download instead of executing, the file opens in the browser window, etc!

Any and all help/advice appreciated!


É

endamcg-logo1b.gif

 
Hi mate,

The problem with not being able to run .cgi is most likely that they have removed this option in the httpd.conf.

The following line is what they likely have:

AddHandler cgi-script .pl

This tells apache that the script is a cgi if the extension is .pl To get both to work correctly then they chouls have a line like the following:

AddHandler cgi-script .cgi .pl

That wouldn't explain why the browser tries to download or gets an error with .pl though, this is most likely a problem with the script that you are trying to execute.

Can you post one of the scripts here?

Hope this helps Wullie

 
Looks like you are not displaying a valid http header. That could be why it is trying to download instead of executing on the server.
 
Hi

Wullie, thanks, good info! I can't post the code, most of the scripts are between 4-6 files and copyrighted! Also, the scripts worked on my previous hosts server so the scripts are ok. The problem happens cos when I changed host and encountered this problem I has to change all the extensions to .pl and modify each script in light of this change. Thats when the problem started.


Beatzin, the exact same files worked with my last host, same http headers etc so i presume it something my current host has enabled/disabled on their servers?

I'd post a link to an axample but I deleted most of them in frustration!!

Should I just give up?


É

endamcg-logo1b.gif

 
It is really difficult to chase this one w/o some code. I would not give up. Rather, I would take an iterative approach to identifying the problem(s). As wullie has pointed out, the web server (for security reasons) will only recognize certain file extensions as 'legal' as CGI programs. But, once all your scripts are renamed and all references internal to the code have been repaired, the naming convention should cease to be a problem. Consequently, I would suspect that your new host may not have all the modules/libraries installed that you are trying to use. Or, that there are some path statements in the code that were specific to the previous environment.

So, I would start with a very simple piece of CGI and make it work on the new host.

Code:
#!/usr/local/bin/perl
use CGI;
use CGI::Carp 'fatalsToBrowser';
my $object = new CGI;
print $object->header,
      $object->start_html,
      '<p>CGI ran, OK.</p>',
      $object->end_html;

Make something like that work. Use the 'fatalsToBrowswer' until you are finished debugging. Then, look at your scripts and make a list of the modules that are used in them. Add a 'use' statement for each module into the simple cgi above. This will show that the new host either does or does not support the modules you are using.

Then, closely check you existing scripts for any system calls or pipes that might be making use of system functions that existed in the previous environment but are not in the new one.

Check for hard coded paths that might be invalid.



any other ideas, anybody? 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Hi goBoating,

I am a complete spastic when it comes to CGI, I know nothing about it so unfortunatly your post was a little over my head! I wouldn't know how to carry out what you said.

However, from what i do understand i'm getting a clearer idea of where to look to start fixing these problems.
Again, I would like to post the scripts but its not possible. I know there's nothing wrong with the scripts, they are all popular scripts downloaded from the top CGI sites, so it must be the server(?) after all the only thing I change is the extension and the references.

Question: assuming I don't have all the modules necessary to run these scripts, do you know if it's standard practice that I demand my host installs these mods? And how about asking my host to enable use of .cgi, is this a reasonable request?
I'm going with this as the first step.


Thanks again guys, I appreciate your help.




É

endamcg-logo1b.gif

 
I think it would be reasonable to expect a hosting service to keep their machines up-to-date. If they are running perl 5.0, then they are a little behind the curve. Whether or not you (an individual) can push them to update their systems?....I don't know. I don't think they'll respond well if you want them to update because their dated systems MIGHT be a problem. If you are going to request work on their part, you'd better make sure they are the problem. Otherwise, you might ruffle some feathers.

Since you can't post some code, I really don't think you stand much of a chance of figuring out your problems unless you gain some understanding of perl and CGI. There are so many issues related to operating systems, perl distributions and versions, modules, syntax, web server configuration, etc, etc, etc, that you will be lucky if you accidentally happen upon the right one or more issues that are causing your problems. I'd start learning how to spell CGI. It is not really that tough, just takes a little work. There are a few faqs in this forum about CGI basics. Also, check the tutorials link on for a few CGI toots. And, of course here we are at TTs, willing to help as we can. [pc2] 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Hi goBoating,

thanks for the advice and the links, much appreciated.

I was thinking, maybe one of the smaller scripts I can install again and post it, one of the GNU licence scripts!
maybe that will tell us something?

I'll probably repost this next week so i'd really appreciate your imput!

Thanks again, to all

Enda É

endamcg-logo1b.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top