Page 1 of 1

PHP and Unix not running

Posted: Mon Mar 15, 2004 3:23 pm
by jenodorf
Hi,

first I am new to this but have tried to cure this problem.

I created a simple PHP file called test.pl which is lsited as follows:-

#!/usr/bin/perl



print "thank god this works!\n";


I uploaded it to my hoster where it resides:-


created a web page with a link to the file "http://www.edwards-micros.co.uk/cgi-bin/test.pl"

If I use putty to get into my site and type ./test.pl the file runs however if I use my link I get a server error and the server log says header errors.

Sorry to be so long winded but my question is is the fault on the server of the script.

I typed perl where and the #!/usr/bin/perl is correct.

I contacted the hoster who basicaly said go away.

I used putty to chmod the files and directory to 777 but it still doesn't work.

Does anyone have any ideas?

thanks

Ian

Re: PHP and Unix not running

Posted: Mon Mar 15, 2004 3:33 pm
by TheBentinel.com
jenodorf wrote: I created a simple PHP file called test.pl which is lsited as follows:-

#!/usr/bin/perl
print "thank god this works!\n";

created a web page with a link to the file "http://www.edwards-micros.co.uk/cgi-bin/test.pl"
That's a perl script, which you would access through cgi. You're getting the error because there has to be a content-type header, or something like that. Straight CGI is a pain...

To make it a PHP script, change it to:

<?php
print("it worked!<br>");
?>

call it test.php and drop it in your root directory, not your cgi-bin directory. Then you can link it from:

http://www.edwards-micros.co.uk/test.php

Hope it helps!

Posted: Tue Mar 16, 2004 8:22 pm
by timvw
#!/usr/bin/perl
print "Content-type: text/html\r\n\r\n";
print "Hello World";

This should work ;) (But perl has some nice classes/modules to generate all this header stuff etc...)