HTML form action="env.cgi" question

Reply

Join Date: Jul 2006
Posts: 8
Reputation: Silentiopk4 is an unknown quantity at this point 
Solved Threads: 0
Silentiopk4 Silentiopk4 is offline Offline
Newbie Poster

HTML form action="env.cgi" question

 
0
  #1
Jul 12th, 2006
I am trying to work through an example from CGI101 (Jaqueline Hamilton's book) and my head is getting turned around. I have two files: env.cgi which looks like
HTML and CSS Syntax (Toggle Plain Text)
  1. #!C:/Perl/bin/perl -wT
  2. use strict;
  3. use CGI qw(:standard);
  4. use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
  5. use CGI::Pretty;
  6. print header;
  7. print start_html("Environment");
  8. foreach my $key (sort(keys(%ENV))) {
  9. print "$key = $ENV{$key}<br>\n";
  10. }
  11. print end_html;

and envform.html which looks like this:
[html]

<html><head><title>Test Form</title></head>
<body>
<form action="env.cgi" method="GET">
Enter your text here:
<input type="text" name="sample_text" size=30>
<input type="submit"><p>
</form>
</body></html>
[/html]

When I type http://localhost/cgi-bin/cgi101/ch03/envform.html into my web browser and hit 'go', I get a 500 Internal Service Error. Both have permissions 755.

I get two lines in C:\Apache2\log\error.log:
[Wed Jul 12 10:13:04 2006] [error] [client 127.0.0.1] C:/Apache2/cgi-bin/cgi101/ch03/envform.html is not executable; ensure interpreted scripts have "#!" first line
[Wed Jul 12 10:13:04 2006] [error] [client 127.0.0.1] (9)Bad file descriptor: don't know how to spawn child process: C:/Apache2/cgi-bin/cgi101/ch03/envform.html


If I go to C:\Apache2\cgi-bin\cgi101\ch03\envform.html and hit 'go', it properly displays the html page, but when I enter text and press the submit button, it displays the contents of the file env.cgi rather than running the script as file:///C:/Apache2/cgi-bin/cgi101/ch...t=my+text+here.

I'm not sure what I'm doing wrong here, but I think I've got a poor understanding of how env.cgi and envform.html are supposed to work together (which is no fault of the tutorial, but of my head full of bad wiring).

Any explanation would be appreciated.

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: HTML form action="env.cgi" question

 
0
  #2
Jul 12th, 2006
This isn't strictly an HTML/CSS/JavaScript question: you're posting in the wrong forum.

I'll answer the parts I can: the HTML form submits the contents of the form to whatever page is specified in the "action" property of the "form" tag.

Your Perl script is supposed to then run, outputting a new HTML page containing the contents of the variables just posted.

I think you have a server configuration problem, as it isn't actually "running" the PERL program.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 182
Reputation: alpha_foobar is an unknown quantity at this point 
Solved Threads: 3
alpha_foobar's Avatar
alpha_foobar alpha_foobar is offline Offline
Junior Poster

Re: HTML form action="env.cgi" question

 
0
  #3
Jul 13th, 2006
I also think its a server conf problem. It sounds like you are not using your cgi, you are just trying to load the html page. Typically you don't have html in your cgi-bin, from your error it sounds like your server is configured to treat everything in the cgi-bin as an executable... so I'd take the html out.. it easier.

Put your html in the public_html directory (or what ever the public html root of your web server directory is).

Change the action property of your form tag to point to the cgi-bin: i.e. make it: /cgi-bin/cgi101/ch03/env.cgi
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 182
Reputation: alpha_foobar is an unknown quantity at this point 
Solved Threads: 3
alpha_foobar's Avatar
alpha_foobar alpha_foobar is offline Offline
Junior Poster

Re: HTML form action="env.cgi" question

 
0
  #4
Jul 13th, 2006
now that should work... but if it doesn't then you should open up the file httpd.conf (or what ever this file is called for apache 2 on windows). Hunt down your cgi settings and change the cgi pattern from cgi-bin/* to *.cgi.

This might be easier... or harder... do either or. Doing both won't break your web site... even if its not the problem
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 8
Reputation: Silentiopk4 is an unknown quantity at this point 
Solved Threads: 0
Silentiopk4 Silentiopk4 is offline Offline
Newbie Poster

Re: HTML form action="env.cgi" question

 
0
  #5
Jul 13th, 2006
Originally Posted by alpha_foobar
now that should work... but if it doesn't then you should open up the file httpd.conf (or what ever this file is called for apache 2 on windows). Hunt down your cgi settings and change the cgi pattern from cgi-bin/* to *.cgi.

This might be easier... or harder... do either or. Doing both won't break your web site... even if its not the problem

I separated my html directories from my .cgi directories, and now everything is working great.

Now I have C:/Apache2/htdocs/(my html docs) and C:/Apache2/cgi-bin/(my cgi scripts) and they cross refer exaclty as they are supposed to.

Thanks for the help.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC