Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

mckarl

Programmer
Joined
May 5, 1999
Messages
147
Location
GB
oki doki everyone!!  (is it me or has andybo been the helpfullest person on tek-tips since ever)<br><br>i am trying to learn to CGI script, using perl. (cos if i was using anything else, activeperl wouldnt work now would it :-) )<br><br>i got my HTML:<br>------------------------------------------------------------<br>&lt;HTML&gt;<br>&lt;TITLE&gt; -- Name CGI script -- &lt;/TITLE&gt;<br><br>&lt;BODY&gt; <br>&lt;P&gt; Welcome to my name CGI script. &lt;/P&gt;<br>&lt;P&gt; Please Enter your name and other details in the prompts below, click submit when you have entered your details, or reset to clear. &lt;/P&gt;<br><br>&lt;FORM METHOD=POST ACTION=&quot;details.cgi&quot;&gt;<br>&lt;PRE&gt;<br>firstname &lt;INPUT TYPE=&quot;text&quot; NAME=&quot;fname&quot; MAXLENGTH=15 SIZE=15&gt;<br>surname   &lt;INPUT TYPE=&quot;text&quot; NAME=&quot;sname&quot; MAXLENGTH=15 SIZE=15&gt;<br>email add &lt;INPUT TYPE=&quot;text&quot; NAME=&quot;email&quot; MAXLENGTH=35 SIZE=35&gt;<br>&lt;INPUT TYPE=&quot;submit&quot; VALUE=&quot;Send Mail&quot;&gt;<br>&lt;INPUT TYPE=&quot;reset&quot;  VALUE=&quot;Clear Details&quot;<br>&lt;/PRE&gt;<br>&lt;/FORM&gt;<br>&lt;/BODY&gt;<br>&lt;/HTML&gt;<br><br>============================================================<br><br>and her's my Perl code:<br><br>------------------------------------------------------------<br><br>read(STDIN,$temp,$ENV{'CONSTANT_LENGTH'});<br>@pairs=split(/&/,$temp);<br>foreach $item(@pairs)<br>{<br>($key,$constant)=split(/=/,$item,2);<br>$content=~tr/+/ /;<br>$content=~s/%(..)/pack(&quot;c&quot;,hex($1))/ge;<br>$fields{$key}=$content;<br>}<br><br>print &quot;Content-type: text/html\n\n&quot;;<br>print &quot;&lt;HTML&gt;\n;<br>print &quot;&lt;BODY BGCOLOR=#FFFFFF&gt;\n&quot;;<br>print &quot;&lt;CENTER&gt;\n&quot;;<br>print &quot;Thank you &lt;BR&gt;\n&quot;;<br>print &quot;$fields{fname} $fields{lname}&lt;/BR&gt;&quot;;<br>print &quot;I will write&lt;BR&gt;\n&quot;;<br>print &quot;you at &lt;BR&gt;\n&quot;;<br>print &quot;&lt;/CENTRE&gt;\n&quot;;<br>print &quot;&lt;/BODY&gt;&lt;/HTML&gt;&quot;;<br><br>============================================================<br><br>now, as i said before, here are the stats:<br>     o   Windows NT Workstation<br>     o   Active Perl<br>     o   I'm thick<br><br>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?<br><br>Please help, like i said, i'm just starting up on this whole cgi thingy wotsit so it'll probably sound really silly. <br><br>Thanks to everyone who replies, and those who look at and think i'm insane, and decide not to answer me.<br><br><br>Many thanks again. Karl. <p> Karl<br><a href=mailto:mc_karl@yahoo.com>mc_karl@yahoo.com</a><br><a href= > </a><br> ~ ~ ~ ~<br>
K A R L<br>
~ ~ ~ ~
 
Flattery will get you everywhere ;^)<br><br>OK, I've not looked at your script in too much detail, because your question seems to be &quot;how the heck do I set up this CGI stuff then?&quot;&nbsp;&nbsp;(Although a quick look at the script and it looks OK.&nbsp;&nbsp;One hint - take a look at the perl CGI stuff.&nbsp;&nbsp;You can get at the documentation using perldoc.)<br><br>So, you have a perl script, you have a server, and you want to run the sctipt as CGI through a web server.&nbsp;&nbsp;First thing - there's no need to compile the perl script - it will just run as is.<br><br>That is, of course, if your web server is set up to run CGI scripts with a &quot;.pl&quot; extension.&nbsp;&nbsp;You will also need to tell the web server which directory you can run the scripts from.<br><br>Now, you say that when you access the script, it gets downloaded to your browser.&nbsp;&nbsp;This tells me that the web server (IIS?) hasn't been set up to recognise &quot;.pl&quot; scripts as being executable. Therefore, the web server is sending it to your browser as a &quot;text/plain&quot; document...<br><br>As you're using Windows NT, I guess you're also using either IIS or Personal Web Server.&nbsp;&nbsp;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.<br><br>Hope this helps. <p> <br><a href=mailto: > </a><br><a href= > </a><br>--<br>
0 1 - Just my two bits
 
hi andy, <br><br>hehehe, diddnt think you'd be the one answering the question :)<br><br>Well, since posting that post, i learned a little something... i need an IIS. :)<br><br>Well, we got one on our server (intranet), but i have <i>no</i> idea how to utalize it to suit my position at the moment. <br><br>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).<br><br>hope you (or anyone else) can help!!<br><br>Thnx in advance...<br><br>Waitin 4 UR rEplI<br><br>Karl... <p> Karl<br><a href=mailto:mc_karl@yahoo.com>mc_karl@yahoo.com</a><br><a href= > </a><br> ~ ~ ~ ~<br>
K A R L<br>
~ ~ ~ ~
 
Sorry, Karl, but I know approximately less than nothing about IIS.&nbsp;&nbsp;However a quick search in the &quot;Find a Forum&quot; box turned up the Microsoft: Internet Information Server forum right here at Tek-Tips :)&nbsp;&nbsp;Head over to <A HREF=" TARGET="_new"> and see if any of the gurus over there can help :) <p> <br><a href=mailto: > </a><br><a href= > </a><br>--<br>
0 1 - Just my two bits
 
Install ActiveState Perl after IIS on your server machine. The installer recognizes the IIS and configures .pl for execution of CGI-Scripts.<br><br>Copy your perl scripts into a web folder (like CGI-BIN) and set executive rights to this folder (Microsoft Management Console).<br><br>Thomas
 
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 <b>ANYTHING</b> so, i'm gonna post another after i have messed around for ages. <br><br>So, <i>now</i> i'm going to say:<br><br><font color=red>o&nbsp;&nbsp;</font>Linux (RedHat 6.2)<br><font color=red>o&nbsp;&nbsp;</font>Apache <br><br>-- how do i do it?<br>-- How can i see if apache is running sussessfully?<br>-- HELP!!<br><br>&quot;:)) <br><br>... anyhow, if you can help, please feel free to post it here, i always check! :)<br><br>P.S. LOL, AndyBo may lose out on that jacket after all!!&nbsp;&nbsp;<br>hehhe.... <br><br>T h a n k s&nbsp;&nbsp;&nbsp;a l l ! ! <br><br>Karl.<br><br> <p> Karl<br><a href=mailto:mc_karl@yahoo.com>mc_karl@yahoo.com</a><br><a href= > </a><br> ~ ~ ~ ~<br>
K A R L<br>
~ ~ ~ ~
 
Darn!&nbsp;&nbsp;Gotta got keep those jacket votes coming in...&nbsp;&nbsp;&lt;grin&gt; ;^)<br><br>OK, to check if Apache is running, log in, or su, to &quot;root&quot; and run &quot;ps fax ¦ grep http&quot;.&nbsp;&nbsp;You should get several &quot;httpd&quot; processes echoed back.&nbsp;&nbsp;If not, then try running &quot;apachectl start&quot;.&nbsp;&nbsp;This should kick things off.&nbsp;&nbsp;(Note, you shouldn't have to do this if you've installed Apache from a RPM or similar.&nbsp;&nbsp;The RPM should set up startup scripts in /etc/rc.d/rc?.d for you.&nbsp;&nbsp;If you've compiled from source, post back and I'll post a startup script for you.)<br><br>Next, check the location of your script.&nbsp;&nbsp;Is it in the standard &quot;cgi-bin&quot; directory?&nbsp;&nbsp;This is usually /home/httpd/cgi-bin on a stock RPM type install.<br><br>Next, who is Apache running as?&nbsp;&nbsp;Again, on a stock install this should be &quot;nobody&quot;.&nbsp;&nbsp;Does &quot;nobody&quot; have access to the cgi-bin directory?<br><br>Oh, don't forget the &quot;ACTION&quot; parameter on your form.&nbsp;&nbsp;It is set to &quot;/cgi-bin/details.cgi&quot; isn't it?<br><br>Next, make sure that the perl script itself is owned by &quot;nobody&quot; and has 755 permissions. (Or 700 if you want to be a touch paranoid...)&nbsp;&nbsp;ie, <FONT FACE=monospace>chmod 755 details.cgi</font><br><br>Finally, check what the access_log and error_log for Apache say.&nbsp;&nbsp;If the CGI script was running, and failing, you should get a 500 error back to the browser.&nbsp;&nbsp;It may be that the submit button isn't asking for what you'd expect.<br><br>Let us know how you get on, and congrats on moving to a real web server platform ;^) <p> <br><a href=mailto: > </a><br><a href= > </a><br>--<br>
0 1 - Just my two bits
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top