| | |
HTML form action="env.cgi" question
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2006
Posts: 8
Reputation:
Solved Threads: 0
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
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.
HTML and CSS Syntax (Toggle Plain Text)
#!C:/Perl/bin/perl -wT use strict; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use CGI::Pretty; print header; print start_html("Environment"); foreach my $key (sort(keys(%ENV))) { print "$key = $ENV{$key}<br>\n"; } 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.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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.
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.
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
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
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
This might be easier... or harder... do either or. Doing both won't break your web site... even if its not the problem
•
•
Join Date: Jul 2006
Posts: 8
Reputation:
Solved Threads: 0
•
•
•
•
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.
![]() |
Similar Threads
- CGI, Tomcat, Perl, not compiling Perl code? (Perl)
- Getting a value into HTML form. (Perl)
- When a host says "included scripts" (Networking Hardware Configuration)
Other Threads in the HTML and CSS Forum
- Previous Thread: Fly-out menu and MAC browsers
- Next Thread: JS opacity menu Problems In IE - rare
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7






