×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

CGI newbie question, come laugh at my question!! (NT/activeperl)

CGI newbie question, come laugh at my question!! (NT/activeperl)

CGI newbie question, come laugh at my question!! (NT/activeperl)

(OP)
oki doki everyone!!  (is it me or has andybo been the helpfullest person on tek-tips since ever)

i am trying to learn to CGI script, using perl. (cos if i was using anything else, activeperl wouldnt work now would it :-) )

i got my HTML:
------------------------------------------------------------
<HTML>
<TITLE> -- Name CGI script -- </TITLE>

<BODY>
<P> Welcome to my name CGI script. </P>
<P> Please Enter your name and other details in the prompts below, click submit when you have entered your details, or reset to clear. </P>

<FORM METHOD=POST ACTION="details.cgi">
<PRE>
firstname <INPUT TYPE="text" NAME="fname" MAXLENGTH=15 SIZE=15>
surname   <INPUT TYPE="text" NAME="sname" MAXLENGTH=15 SIZE=15>
email add <INPUT TYPE="text" NAME="email" MAXLENGTH=35 SIZE=35>
<INPUT TYPE="submit" VALUE="Send Mail">
<INPUT TYPE="reset"  VALUE="Clear Details"
</PRE>
</FORM>
</BODY>
</HTML>

============================================================

and her's my Perl code:

------------------------------------------------------------

read(STDIN,$temp,$ENV{'CONSTANT_LENGTH'});
@pairs=split(/&/,$temp);
foreach $item(@pairs)
{
($key,$constant)=split(/=/,$item,2);
$content=~tr/+/ /;
$content=~s/%(..)/pack("c",hex($1))/ge;
$fields{$key}=$content;
}

print "Content-type: text/html\n\n";
print "<HTML>\n;
print "<BODY BGCOLOR=#FFFFFF>\n";
print "<CENTER>\n";
print "Thank you <BR>\n";
print "$fields{fname} $fields{lname}</BR>";
print "I will write<BR>\n";
print "you at <BR>\n";
print "</CENTRE>\n";
print "</BODY></HTML>";

============================================================

now, as i said before, here are the stats:
     o   Windows NT Workstation
     o   Active Perl
     o   I'm thick

but i have a real big probz. how can i compile a .pl script into a cgi script, without it trying to download it all the time?

Please help, like i said, i'm just starting up on this whole cgi thingy wotsit so it'll probably sound really silly.

Thanks to everyone who replies, and those who look at and think i'm insane, and decide not to answer me.


Many thanks again. Karl.

Karl
mc_karl@yahoo.com

~ ~ ~ ~
K A R L
~ ~ ~ ~

RE: CGI newbie question, come laugh at my question!! (NT/activeperl)

Flattery will get you everywhere ;^)

OK, I've not looked at your script in too much detail, because your question seems to be "how the heck do I set up this CGI stuff then?"  (Although a quick look at the script and it looks OK.  One hint - take a look at the perl CGI stuff.  You can get at the documentation using perldoc.)

So, you have a perl script, you have a server, and you want to run the sctipt as CGI through a web server.  First thing - there's no need to compile the perl script - it will just run as is.

That is, of course, if your web server is set up to run CGI scripts with a ".pl" extension.  You will also need to tell the web server which directory you can run the scripts from.

Now, you say that when you access the script, it gets downloaded to your browser.  This tells me that the web server (IIS?) hasn't been set up to recognise ".pl" scripts as being executable. Therefore, the web server is sending it to your browser as a "text/plain" document...

As you're using Windows NT, I guess you're also using either IIS or Personal Web Server.  I don't know how to set these up for executing CGI, but I'm sure there will be an IIS forum elsewhere on Tek-Tips.

Hope this helps.




--
0 1 - Just my two bits

RE: CGI newbie question, come laugh at my question!! (NT/activeperl)

(OP)
hi andy,

hehehe, diddnt think you'd be the one answering the question :)

Well, since posting that post, i learned a little something... i need an IIS. :)

Well, we got one on our server (intranet), but i have no idea how to utalize it to suit my position at the moment.

Could it be possible that you know how to access the html browser through the servers IIS and into my perl CGI script? (c'mon, you know everything else).

hope you (or anyone else) can help!!

Thnx in advance...

Waitin 4 UR rEplI

Karl...

Karl
mc_karl@yahoo.com

~ ~ ~ ~
K A R L
~ ~ ~ ~

RE: CGI newbie question, come laugh at my question!! (NT/activeperl)

Sorry, Karl, but I know approximately less than nothing about IIS.  However a quick search in the "Find a Forum" box turned up the Microsoft: Internet Information Server forum right here at Tek-Tips :)  Head over to http://www.tek-tips.com/gthreadminder.cfm/lev2/3/lev3/22/pid/41 and see if any of the gurus over there can help :)




--
0 1 - Just my two bits

RE: CGI newbie question, come laugh at my question!! (NT/activeperl)

Install ActiveState Perl after IIS on your server machine. The installer recognizes the IIS and configures .pl for execution of CGI-Scripts.

Copy your perl scripts into a web folder (like CGI-BIN) and set executive rights to this folder (Microsoft Management Console).

Thomas

RE: CGI newbie question, come laugh at my question!! (NT/activeperl)

(OP)
wwwaaaaaaaaaawww, well, i though to myself, sod-it, i'll put it on my linux box with apache, and now, well, it comes up great, but when i click submit, it doesnt do ANYTHING so, i'm gonna post another after i have messed around for ages.

So, now i'm going to say:

o  Linux (RedHat 6.2)
o  Apache

-- how do i do it?
-- How can i see if apache is running sussessfully?
-- HELP!!

":))

... anyhow, if you can help, please feel free to post it here, i always check! :)

P.S. LOL, AndyBo may lose out on that jacket after all!!  
hehhe....

T h a n k s   a l l ! !

Karl.

Karl
mc_karl@yahoo.com

~ ~ ~ ~
K A R L
~ ~ ~ ~

RE: CGI newbie question, come laugh at my question!! (NT/activeperl)

Darn!  Gotta got keep those jacket votes coming in...  <grin> ;^)

OK, to check if Apache is running, log in, or su, to "root" and run "ps fax ¦ grep http".  You should get several "httpd" processes echoed back.  If not, then try running "apachectl start".  This should kick things off.  (Note, you shouldn't have to do this if you've installed Apache from a RPM or similar.  The RPM should set up startup scripts in /etc/rc.d/rc?.d for you.  If you've compiled from source, post back and I'll post a startup script for you.)

Next, check the location of your script.  Is it in the standard "cgi-bin" directory?  This is usually /home/httpd/cgi-bin on a stock RPM type install.

Next, who is Apache running as?  Again, on a stock install this should be "nobody".  Does "nobody" have access to the cgi-bin directory?

Oh, don't forget the "ACTION" parameter on your form.  It is set to "/cgi-bin/details.cgi" isn't it?

Next, make sure that the perl script itself is owned by "nobody" and has 755 permissions. (Or 700 if you want to be a touch paranoid...)  ie, chmod 755 details.cgi

Finally, check what the access_log and error_log for Apache say.  If the CGI script was running, and failing, you should get a 500 error back to the browser.  It may be that the submit button isn't asking for what you'd expect.

Let us know how you get on, and congrats on moving to a real web server platform ;^)




--
0 1 - Just my two bits

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close