This is topic Perl/CGI question in forum Books, Films, Food and Culture at Hatrack River Forum.


To visit this topic, use this URL:
http://www.hatrack.com/ubb/main/ultimatebb.php?ubb=get_topic;f=2;t=047172

Posted by Boris (Member # 6935) on :
 
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.
 
Posted by xnera (Member # 187) on :
 
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.
 
Posted by Chanie (Member # 9544) on :
 
#!/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)";
 
Posted by Boris (Member # 6935) on :
 
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.
 


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