Cannot get test.pl running from CGI directory

I'm guessing I'm missing something obvious but here goes.

I installed apache on SLES10SP2 via the RPMs with SLES10SP2.  By default it looks like document root is /srv/www/htdocs and CGI-BIN is /srv/www/cgi-bin

contents of /srv/www/cgi-bin are
testserv:/srv/www/cgi-bin # ls -1
htsearch
info2html
info2html.conf
infocat
qtest
test.cgi
test.pl
testserv:/srv/www/cgi-bin #

test.cgi and test.pl are scripts I put in myself.  The rest were installed with the RPM.  Loading the other CGI scripts in browser works but loading in test.cgi and test.pl do not

My browser gets a pop up window saying:

"You have chosen to open test.pl which is a Perl script" and then "What should firefox do with this file?"

The only thing I could think of was that it didn't recognize .cgi or .pl.  

If I grep in mime.types I get:

testserv:/etc/apache2 # grep -i perl mime.types
application/x-perl pl pm al perl
testserv:/etc/apache2 # grep -i cgi mime.types
application/x-cgi cgi
testserv:/etc/apache2 #

I also added

AddHandler cgi-script .pl .cgi

in the default-server.conf file right under the DocumentRoot statement.  Still no go (the apache configuration is spread amongst many different *.conf files it seems when installing from RPM).

Anyhow, any ideas or thoughts?  

Thanks!
LVL 5
uaynebAsked:
Who is Participating?
 
Adam314Commented:
Are you sure the test.pl you posted is the one you are getting?  From your telnet output, it doesn't look like you are getting the content-type header - which would explain why firefox is asking you to download the file, rather than display it.  Also, the output includes "<br>" lines and a date line; the perl script you posted does have the content-type header, but no "<br>", and no date, so it looks like you are getting a different test.pl script.

Try double-checking for any Alias or ScriptAlias directives in you apache config files.  You could also try posting here your config files.
0
 
uaynebAuthor Commented:
more info on the script itself.  test.pl and test.cgi are the same

testserv:/srv/www/cgi-bin # cat test.pl
#!/usr/bin/perl

print "Content-type:/text/html\n\n";
print "hello world\n";

testserv:/srv/www/cgi-bin # ls -l test.pl
-rwxr-xr-x 1 root root 77 Apr 21 01:27 test.pl
testserv:/srv/www/cgi-bin #

0
 
uaynebAuthor Commented:
More info - is it something with my browser?  When i telnet to port 80 and do a
GET /cgi-bin/test.pl

it's fine.  I added a print out of localtime() in the script just so I could see it getting a new datestamp each time I tried to access the perl script.

Also no errorlog entries.  

testone:~ # telnet 172.25.12.34 80
Trying 172.25.12.34...
Connected to 172.25.12.34.
Escape character is '^]'.
GET /cgi-bin/test.pl
hello world
<br>
 date: Wed Apr 21 02:14:01 2010
<br>Connection closed by foreign host.
testone:~ #

kinda stumped :(
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
gelonidaCommented:
It should'nt really be a browser issue.

Either your server executes the cgi-script ot if badly configured it serves the contents.

What you could check though:

 Did you flush your browser's cache?
It might be, that you fixed somehting in the server, but that your browser still returns the old data.

What might be as well is, that your browser is configured for virtual servers and that your
simple telnet request falls into the default configuration, whereas your browser request falls into another config.


What's the url  you entered in the browser? http://172.25.12.34/cgi-bin/test.pl

did you try the same url with wget?
THis should allow you to eliminate the browser as culprit

0
 
uaynebAuthor Commented:
I didn't try the wget yet, just telnet locally to port 80.  That's what lead me to believe it might be a browser issue.

Wget transfers the files and saves them locally.

Also, yes that is the URL I entered in my browser

Thanks for the tips - any other ideas?
0
 
gelonidaCommented:
In order to be sure, you really get what you think you are fetching, you could
rename the perl script, restart apache and try with your browser and tyry with telnet again and with wget.

you could try folowing wget command:
wget -S -O - http://172.25.12.34/cgi-bin/test.pl

It will print out the headers returned by your server and print the file to stdout instead of saving it to a file.

I'd suggest you check what result you get with wgetn and post it here.

By the way: Did you try to clear the cache of your browser?
0
 
uaynebAuthor Commented:
Hi there,
i did change the script to include newlines, etc... in between my first post and the next post.  Sorry I did not mention that.  Good thought.   Yes it is the same script.

Anyway, so what it ended up being is at typo.  In a haze of loopiness I thought "well maybe my content-type is not correct and it should be mime something or perl something" which shows you how loopy I was because of course it is supposed to be text/html, not sure why I doubted it.

But anyway, because of my haze of loopiness I checked the Content-type and from there spotted my typo:

print "Content-type:/text/html\n\n";

Should be

print "Content-type:text/html\n\n";

(no forward slash before the word "text")

And it worked :D

Thanks guys!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.