I am having a problem that I assume is a set-up problem but I don't know which area to look at to fix it. Hopefully someone here can point me in the right direction.
I can't get the simple Perl "Hello World" script to work.
Oh, it does print "Hello World" OK but it also prints the "Content" line as text rather than using it as a directive.
Two different servers (both CentOs 5) and both IE and Firefox are doing the same thing.
I first tried a JavaScript program (free online shopping cart) and it wouldn't work properly. So, I changed to CGI and can't get it working OK either.
What does work: CGI/Perl visitor count program. Count.log and main.log exist and get updated and display the updated count in the browser OK.
What doesn't work: "content" line is seen as text. I can't create a file using CGI. I can append to one but I can't create one. I have tried a CGI shopping cart (Commerce) which has an install script. It displays the first page OK but when I click on "Continue" I get the same page again. The script says clicking on "Continue" should submit a form (Post) with a name of "step2. An IF statement should see that name and go to the step2 subroutine. It doesn't. It falls through to the ELSE and displays the same page. A Print command shows the name is blank after the click. The browser knows about the form because a refresh tells me about the stale form data.
I have the AddHandler lines and the ExCGI option in my http config. I have checked that all spelling and cases are OK. Carp Fatal to Browser is not showing any errors. Server error log doesn't seem unhappy either. I have done some searching in news groups and Deja, ooops sorry, Google and didn't find anything that helped.
Where do I look next?
Tech wrote on Mon, 29 Sep 2008 13:01:26 +0800:
Oh, it does print "Hello World" OK but it also prints the "Content" line as text rather than using it as a directive.
This is not a setup problem and not a CentOS problem. Your script is probably wrong in some code. I assume with "Content" line you might mean an HTTP header. There is no such header (there are headers starting with this string, though). I think your question is better suited for a Perl or CGI programming newsgroup.
Kai
Kai Schaetzl wrote:
Tech wrote on Mon, 29 Sep 2008 13:01:26 +0800:
Oh, it does print "Hello World" OK but it also prints the "Content" line as text rather than using it as a directive.
This is not a setup problem and not a CentOS problem. Your script is probably wrong in some code. I assume with "Content" line you might mean an HTTP header. There is no such header (there are headers starting with this string, though). I think your question is better suited for a Perl or CGI programming newsgroup.
Kai
Hi,
Thanks for your reply.
By "Content" line I meant this line:
print "Content-type: text/html\n\n";
I have tried many scripts, they all do this. I have problems with JavaScript too so I am not sure yet about this just being a Perl or CGI problem. I might even have multiple problems. I can see the possibility of permission problems, Perl problems, CGI problems, and/or browser problems. I am running the latest released version of all including IE and Firefox. All I do know is what all the examples that show this as working don't work. I have the book, CGI Programing 101, and can't get its examples to work.
It is very frustrating.
Mel
On Sep 29, 2008, at 10:11 AM, tech wrote:
Thanks for your reply.
By "Content" line I meant this line:
print "Content-type: text/html\n\n";
I have tried many scripts, they all do this. I have problems with JavaScript too so I am not sure yet about this just being a Perl or CGI problem. I might even have multiple problems. I can see the possibility of permission problems, Perl problems, CGI problems, and/ or browser problems. I am running the latest released version of all including IE and Firefox. All I do know is what all the examples that show this as working don't work. I have the book, CGI Programing 101, and can't get its examples to work.
i'm sorry to hear you're frustrated. it would be easier to troubleshoot this problem if you were to post links to the following:
* your Perl script * the Apache access and error logs showing what happens when you try to hit the CGI from a browser * the relevant Apache configs (vhost, .htaccess, whatever)
-steve
-- If this were played upon a stage now, I could condemn it as an improbable fiction. - Fabian, Twelfth Night, III,v
Steve Huff wrote: it would be easier to troubleshoot this problem if you were to post links to the following:
- your Perl script
- the Apache access and error logs showing what happens when you try to
hit the CGI from a browser
- the relevant Apache configs (vhost, .htaccess, whatever)
-steve
Steve,
Thanks for the reply. Instead of links I will post the code as it is very short.
This is what the browser displays all on one line exactly as shown:
Content-type: text/html Hello, world!
Here is the index.html file:
<html> <HEAD><TITLE>Tech</TITLE> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> </head> <body> <p><!--#exec cmd="perl ./cgi-bin/hello.cgi"--></p> </body> </html>
Here is the hello.cgi file:
#!/bin/perl print "Content-type: text/html\n\n"; print "Hello, world!\n";
Here are the lines from the access log:
220.241.99.252 - - [29/Sep/2008:23:22:22 +0800] "GET / HTTP/1.1" 200 189 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008052912 Firefox/3.0"
The error log has no lines for this access.
Mel
nate wrote:
Do you have server side includes turned on in apache? (in the <Directory> section typically)
Are your includes configured with the NoExec option?
Hi Nate,
Don't think so. I have +Includes and ExecCGI in directory options. NoExec does not appear anywhere in HTTP.conf or in perl.conf
Mel
tech wrote:
Don't think so. I have +Includes and ExecCGI in directory options. NoExec does not appear anywhere in HTTP.conf or in perl.conf
Have you tried variations on the path? e.g if your executing a shell I don't think ./cgi-bin/ would be a valid path, it would be relative to the file system itself.
Also is the html file being called named .shtml or .html ? Unless you changed the default behavior of apache server side includes I believe are ignored unless the extension is .shtml.
Example from my personal web site:
<!--#include virtual="/cgi-bin/multimon-new.cgi" -->
Calls the UPS status cgi and displays it inline on the site: http://portal.aphroland.org/
nate
nate wrote: Have you tried variations on the path? e.g if your executing a shell I don't think ./cgi-bin/ would be a valid path, it would be relative to the file system itself.
Example from my personal web site:
<!--#include virtual="/cgi-bin/multimon-new.cgi" -->
Nate,
The ./cgi-bin/ is under public_html. It is set in http.conf as a CGI directory. The files are found OK. But, as mentioned, I have been confusing the proverbial apples and oranges. I will put my CGI tutorial books away and learn how to call CGI and JavaScripts from HTML to right way.
Thanks again.
Mel
tech wrote:
The ./cgi-bin/ is under public_html. It is set in http.conf as a CGI directory. The files are found OK. But, as mentioned, I have been confusing the proverbial apples and oranges. I will put my CGI tutorial books away and learn how to call CGI and JavaScripts from HTML to right way.
Try calling the cgi directly like my example instead of executing perl in a shell.
nate
On Sep 29, 2008, at 11:32 AM, tech wrote:
Steve Huff wrote: it would be easier to troubleshoot this problem if you were to post links to the following:
- your Perl script
- the Apache access and error logs showing what happens when you
try to hit the CGI from a browser
- the relevant Apache configs (vhost, .htaccess, whatever)
-steve
Steve,
Thanks for the reply. Instead of links I will post the code as it is very short.
This is what the browser displays all on one line exactly as shown:
Content-type: text/html Hello, world!
Here is the index.html file:
<html> <HEAD><TITLE>Tech</TITLE> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> </head> <body> <p><!--#exec cmd="perl ./cgi-bin/hello.cgi"--></p> </body> </html>
Here is the hello.cgi file:
#!/bin/perl print "Content-type: text/html\n\n"; print "Hello, world!\n";
Here are the lines from the access log:
220.241.99.252 - - [29/Sep/2008:23:22:22 +0800] "GET / HTTP/1.1" 200 189 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/ 2008052912 Firefox/3.0"
The error log has no lines for this access.
Mel
I believe your HTML file has already caused the server to emit the
Content-type: text/html
line before it gets to the exec line; so when the perl program prints that line, it appears in the normal text output instead of as an HTTP directive. If you want to use the perl program this way, you're better of using it as a CGI instead of a server include file.
Tony Schreiner
On Mon, Sep 29, 2008 at 12:11:32PM -0400, Tony Schreiner wrote:
On Sep 29, 2008, at 11:32 AM, tech wrote:
<html> <HEAD><TITLE>Tech</TITLE> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> </head> <body> <p><!--#exec cmd="perl ./cgi-bin/hello.cgi"--></p> </body> </html>
Here is the hello.cgi file:
#!/bin/perl print "Content-type: text/html\n\n"; print "Hello, world!\n";
I believe your HTML file has already caused the server to emit the
Right. The O/P is confusing his weasels. He's writing a CGI script but using an _include_ script. Two totally different things.
PEBKAC.
Stephen Harris wrote: Right. The O/P is confusing his weasels. He's writing a CGI script but using an _include_ script. Two totally different things.
Stephen,
Thank you.
I appreciate your time and patience. I now know what to go find to fix this.
I was trying to do this the same way I installed the common visitor counter which worked.
Thanks to all who pointed me in the right direction.
as I said this has really nothing to do with CentOS, you should go to a Usenet newsgroup that specializes in this stuff.
Kai
tech wrote:
Kai Schaetzl wrote:
Tech wrote on Mon, 29 Sep 2008 13:01:26 +0800:
Oh, it does print "Hello World" OK but it also prints the "Content" line as text rather than using it as a directive.
This is not a setup problem and not a CentOS problem. Your script is probably wrong in some code. I assume with "Content" line you might mean an HTTP header. There is no such header (there are headers starting with this string, though). I think your question is better suited for a Perl or CGI programming newsgroup.
Kai
Hi,
Thanks for your reply.
By "Content" line I meant this line:
print "Content-type: text/html\n\n";
I have tried many scripts, they all do this. I have problems with JavaScript too so I am not sure yet about this just being a Perl or CGI problem. I might even have multiple problems. I can see the possibility of permission problems, Perl problems, CGI problems, and/or browser problems. I am running the latest released version of all including IE and Firefox. All I do know is what all the examples that show this as working don't work. I have the book, CGI Programing 101, and can't get its examples to work.
It is very frustrating.
If you execute this from the command line, you should see the Content-type: header as part of the text output. When apache runs it under the cgi interface the parts up to the blank line ("\n\n") should be included in the http headers and the rest in the body of the response. If you have copied the example files from somewhere, be sure that they aren't formated for windows with extra carriage returns embedded and if you are entering your own code be sure you don't output anything but valid header lines before the blank line.
On Mon, Sep 29, 2008 at 12:01 AM, tech tech@laamail.com wrote:
I am having a problem that I assume is a set-up problem but I don't know which area to look at to fix it. Hopefully someone here can point me in the right direction.
I can't get the simple Perl "Hello World" script to work.
I can't get the "Hello World" program in the C++ book I began reading to work. Seems to compile without errors, but nothing on my CRT. Will try it again and start a thread here... :-)
On Mon, Sep 29, 2008 at 09:29:06PM -0500, Lanny Marcus wrote:
On Mon, Sep 29, 2008 at 12:01 AM, tech tech@laamail.com wrote:
I am having a problem that I assume is a set-up problem but I don't know which area to look at to fix it. Hopefully someone here can point me in the right direction.
I can't get the simple Perl "Hello World" script to work.
I can't get the "Hello World" program in the C++ book I began reading to work. Seems to compile without errors, but nothing on my CRT. Will try it again and start a thread here... :-)
Let me guess...
you named it "test", right? Then when you run "test" "nothing" happens?
two things: 1. there's already a program named test, which displays no output, it merely has an exit status. 2. for a program in your current directory, run it with a preceding "./", e.g., "./test"--because "." is not in the path (and shouldn't be).
I can't get the simple Perl "Hello World" script to work.
I can't get the "Hello World" program in the C++ book I
began reading
to work. Seems to compile without errors, but nothing on my
CRT. Will
try it again and start a thread here... :-)
Let me guess...
you named it "test", right? Then when you run "test" "nothing" happens?
two things:
- there's already a program named test, which displays no
output, it merely has an exit status. 2. for a program in your current directory, run it with a preceding "./", e.g., "./test"--because "." is not in the path (and shouldn't be).
This reminds me. I tried playing with c++ once back in like 96. I made a hello program on my windows 95 system and then forgot about it. I kept that system and never reformatted all the way through to windows xp. I could not believe it was working.
One day in 2002 or so, I entered the command prompt and bored, typed 'hello' to my computer. It replied by saying 'hello bob, about time you got this working'
So, after I got spooked, I remembered that program from years ago...still on the computer.
I know off topic, but it was funny
On Mon, Sep 29, 2008 at 7:50 PM, Bob Hoffman bob@bobhoffman.com wrote:
I know off topic, but it was funny
I think humor is almost always on topic, at least if there's some relevance to the subject at hand, like here.
Thanks for the laugh.
mhr
On Mon, Sep 29, 2008 at 7:32 PM, fred smith fredex@fcshome.stoneham.ma.us wrote:
two things:
- there's already a program named test, which displays no output,
it merely has an exit status.
And, in general, it is a poor idea showing little imagination to name a test program "test."
- for a program in your current directory, run it with a preceding "./",
e.g., "./test"--because "." is not in the path (and shouldn't be).
I rather like having . in my path, and up front. However, programs should reflect something of their content. The Hello World program could much more recognizably (and future-referentially) named "hello."
It's one of those mornings....
mhr