?
Solved

Perl CGI module not available, having trouble installing

Posted on 2003-03-19
5
Medium Priority
?
367 Views
Last Modified: 2013-12-15
Running Mandrake Linux 9.  I'd think that the CGI module is part of the default perl build, but apparently not.  I am trying to use the CGI module to extract values from a form.  My cgi looks like:

#!/usr/bin/perl
use CGI;
$q = new CGI;
$username = $q->param('username');
$password = $q->param('password');
... MORE CODE ...

When I use the form in the test.html file I get a "500 Internal Server Error".  The apache error logs just say:

[Thu Mar 20 21:08:42 2003] [error] (2)No such file or directory: exec of /var/www/cgi-bin/admin.cgi failed
[Thu Mar 20 21:08:42 2003] [error] [client <IP ADDR>] Premature end of script headers: /var/www/cgi-bin/admin.cgi

So, I cant find anything wrong in my script, so I run the script through the console.  

$ perl -D admin.cgi
Recompile perl with -DDEBUGGING to use -D switch
Can't locate CGI.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at admin.cgi line 11.
BEGIN failed--compilation aborted at admin.cgi line 11.

This gives me the impression that I don't have the CGI module (regardless of the fact perl is not compiled corectly for debugging).  So I look in </usr/lib/perl5/vendor_perl/5.8.0> and there is a CGI/ dir, but the dir is empty.  So first I go to mirror that has Mandrake RPMs.  I get "perl-CGI-2.810-3mdk.noarch.rpm" and run it.

# rpm -i perl-CGI-2.810-3mdk.noarch.rpm
error: unpacking of archive failed on file
/usr/lib/perl5/vendor_perl/5.8.0/CGI.pm;3e7a714c: cpio: MD5 sum mismatch

So now I am pretty much clueless, so I try going to www.cpan.org and downloading "CGI.pm-2.91.tar.gz".  So I think maybe this will work so I give is a shot.  

# gunzip CGI.pm-2.91.tar.gz
gunzip: CGI.pm-2.91.tar.gz: invalid compressed data--crc error
gunzip: CGI.pm-2.91.tar.gz: invalid compressed data--length error

SOOOO... Is anyone else as baffled as I am?  Anyone's insight would be helpful!

Thanks,
Matthew Brainard
brainarm_mweb@yahoo.com
0
Comment
Question by:brainarm38802
5 Comments
 
LVL 6

Expert Comment

by:Chester_M_Ragel
ID: 8172082
Its like some download problem. Download from here and try.
http://stein.cshl.org/WWW/software/CGI/CGI.pm.tar.gz
0
 

Author Comment

by:brainarm38802
ID: 8176428
Ok, I got the CGI package installed simply by copying the "CGI.pm" file and all files in "CGI/" to </usr/lib/perl5/vendor_perl/5.8.0/[CGI/]>.  And when I run the script through the command line, it works fine (no errors that is).  But still when I run it through the browser I still get the "500 Internal Server Error", the logs look like:

[Fri Mar 21 14:41:34 2003] [error] (2)No such file or directory: exec of /var/www/cgi-bin/admin.cgi failed
[Fri Mar 21 14:41:34 2003] [error] [client 65.24.211.150] Premature end of script headers: /var/www/cgi-bin/admin.cgi

Now I cant quite figure out why.  My html file is:

<html>
<head>
<title>deljvs-mweb.treca.org</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script src="/javascript/common.js" name="common">
</script>
</head>

<body>
<div align="center">
  <h1>deljvs-mweb.treca.org</h1>
  <hr noshade>
  <h3 align="left">Administrator Login</h3>
  <div align="left">
    <form action="/cgi-bin/admin.cgi" method="post" name="acctreq" id="acctreq" onSumbit="verifyRequired()">
      <input type=hidden name="subject" value="Account Request">
      <table width="80%" border="0" cellspacing="0">
        <tr>
          <td width="38%">Username:</td>
          <td width="62%"><input name="username" type="text" id="username" size="10" maxlength="8"></td>
        </tr>
        <tr>
          <td> Password:</td>
          <td><input name="password" type="password" size="10" maxlength="16"></td>
        </tr>
        <tr>
          <td colspan="2"><div align="center">
              <input type="submit" name="Submit" value="Submit">
              <input name="Reset" type="reset" id="Reset" value="Reset">
            </div></td>
        </tr>
      </table>
    </form>
  </div>
  <p align="left">&nbsp;</p>
</div>
</body>
</html>

And my CGI script is:

#!/usr/bin/perl
use CGI;
$q = new CGI;
$username = $q->param('username');
$password = $q->param('password');
if (($username == "brainarm") && ($password == "test")) {
  print "Content-type: text/html\n\n";
  print "<html>\n<head>\n<title>Administator's Only</title>\n<\head>\n<body>\n";
  print "<center>\n<h1>deljvs-mweb.treca.org</h1>\n<p><hr><p>\n";
  print "<h3>Administrator View: $username</h3>\n</center>\n";
  print "</html>";
} else {
  print "Content-type: text/html\n\n";
  print "<html>\n";
  print "<i>Access Denied!  Press your browser's \"back\" button to try again.</i>\n";
  print "</html>";


Any suggestions?  I dont know why I am getting an error!

Thanks,
Matthew Brainard
brainarm_mweb@yahoo.com
0
 
LVL 15

Expert Comment

by:samri
ID: 8180032
hi Matthew,

DOes you scripts run from command line,

ie doing

perl /var/www/cgi-bin/admin.cgi

did produce a correct http header, and not errors.

cheers.
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 375 total points
ID: 8183965
either your script has not the propper permissions
  1) x bit
  2) execute and read permission for user running web-server
or it's the common hashbang problem, means
  the very first line does not give a valid perl executable
or you have returns in your file, in particular at end of very first (hashbang) line.

Check all these ...
0
 

Author Comment

by:brainarm38802
ID: 8196687
ok, I want to thank Chester_M_Ragel.  He suggested I try a new download site.  That got the CGI module on my box.  

But it was ahoffmann that answered my scripting question.  What the problem was, the file was a dos file.  So it was creating line breaks after all of them, including the hashbang.  
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome back to our beginners guide of the popular Unix tool, cron. If you missed part one where we introduced this tool, the link is below. We left off learning how to build a simple script to schedule automatic back ups. Now, we’ll learn how to se…
This article explains how to use the rsync command to create backups and sync data across hosts. Rsync is a very useful command that is often used to copy data, make backups, migrate hosts, and bridge the gap between site staging and production envi…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

616 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question