943,722 Members | Top Members by Rank

Ad:
Jul 12th, 2006
0

HTML form action="env.cgi" question

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Silentiopk4 is offline Offline
8 posts
since Jul 2006
Jul 12th, 2006
0

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

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.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Jul 13th, 2006
0

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

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
Reputation Points: 20
Solved Threads: 5
Junior Poster
alpha_foobar is offline Offline
182 posts
since May 2005
Jul 13th, 2006
0

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

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
Reputation Points: 20
Solved Threads: 5
Junior Poster
alpha_foobar is offline Offline
182 posts
since May 2005
Jul 13th, 2006
0

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

Quote 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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Silentiopk4 is offline Offline
8 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: Fly-out menu and MAC browsers
Next Thread in HTML and CSS Forum Timeline: JS opacity menu Problems In IE - rare





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC