Link to home
Start Free TrialLog in
Avatar of uayneb
uayneb

asked on

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!
Avatar of uayneb
uayneb

ASKER

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 #

Avatar of uayneb

ASKER

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 :(
SOLUTION
Avatar of gelonida
gelonida
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of uayneb

ASKER

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?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
Avatar of uayneb

ASKER

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!