?
Solved

Perl CGI module not available, having trouble installing

Posted on 2003-03-19
5
Medium Priority
?
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

762 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