FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » Perl/CGI question

   
Author Topic: Perl/CGI question
Boris
Member
Member # 6935

 - posted      Profile for Boris   Email Boris         Edit/Delete Post 
I thought I posted this, but I guess the forum gods found me unworthy on my first attempt.

Anyway, I'm trying to get an HTML form processing script going for the company website here, so I'm diving head-first into perl. I've found some online tutorials that are pretty handy and have learned most of what I need. Unfortunately, I never enjoyed coding enough to want to do things like parsing, so I did a little research and found the parsing features of cgi-lib, which are supposed to do all the work for you. Unfortunately, every time I link it into one of the scripts I make, the web server I'm using returns a big fat error message. I've run the script in a telnet session and it says that the require command is not recognized. Here's the HTML form and script I'm using. I've changed all the <>'s to ()'s so I can actually post this [Big Grin]

quote:

(HTML)
(BODY)
(FORM method="post" action="http://forms.rainforesttelecom.com/cgi-bin/testform.cgi">
Name: (INPUT TYPE="text" name="username" size="30")
(BR)
(INPUT TYPE="submit")
(/FORM)
(/BODY)
(/HTML)

quote:

#!/usr/bin/perl

require "cgi-lib.cgi";

&ReadParse(*input);

$uname= $input{'username'};

print "Content-type: text/html\n\n";
print "(HTML)(BODY)";

print "Hi $uname, welcome!";

print "(/BODY)(/HTML)";

Am I being stupid or missing something or is there something I need to do with the server to get this working? Any CGI script I write that doesn't need an external script works fine. I have perl installed in the web server, so that's not the problem (I don't think) and CGI is enabled for the test site I'm using. I've also tried using do and use instead of require. Any help or advise would be greatly appreciated.
Posts: 3003 | Registered: Oct 2004  |  IP: Logged | Report this post to a Moderator
xnera
Member
Member # 187

 - posted      Profile for xnera   Email xnera         Edit/Delete Post 
Been a while since I've done any coding, and I haven't worked with CGI much, but when I was slinging perl at the screen one of the most common problems I had were modules that were missing or weren't loaded properly (i.e., the wrong version loaded). So the first thing I'd do would be to check that cgi-lib is INDEED loaded.

Are you sure "cgi-lib.cgi" is correct? That extension looks weird to me. Don't perl modules normally use .pm? Also, I'm fairly certain the most common way of require the CGI module in a perl program is

quote:

use CGI;

So maybe try that instead.
Posts: 1805 | Registered: Jun 1999  |  IP: Logged | Report this post to a Moderator
Chanie
Member
Member # 9544

 - posted      Profile for Chanie   Email Chanie         Edit/Delete Post 
#!/usr/bin/perl

use strict;
use CGI qw/:all/;

my $uname = param('username');


print "Content-type: text/html\n\n";
print "(HTML)(BODY)";

print "Hi $uname, welcome!";

print "(/BODY)(/HTML)";

Posts: 159 | Registered: Jun 2006  |  IP: Logged | Report this post to a Moderator
Boris
Member
Member # 6935

 - posted      Profile for Boris   Email Boris         Edit/Delete Post 
Heh [Big Grin] I figured it out. I hadn't properly set the permissions on the cgi-bin directory on the web server. Works now [Big Grin] That and I was using the wrong method to run the script. "perl" aparently works a lot better than "bash" for running perl scripts...funny how that works.
Posts: 3003 | Registered: Oct 2004  |  IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2