The script looks ok to me... The difference that you probably see is the first line. This is the "shebang", a line that tells the script interpreter which application the script should be interpreted with. This, together with the permissions you've provided, makes the script "self-executing", in that the shell automatically invokes the php executable when it finds the shebang and it feeds the rest of the script to it.
You could obtain the same result by removing the shebang and passing the file as a parameter to the php executable, although it would be less practical in many cases. Two possibilities: one, your host does not allow shell php scripts. In this case, you're out of luck (you *could* execute your script through the web using a shell interface like lynx or curl, but that's probably not what you want to do, and it would mean some serious security implications). The other possibility is that you're simply looking for the PHP executable in the wrong place (only because the author of the book had it in /usr/bin doesn't mean you will, too). It most likely is in /usr/local/bin, so that your shebang should read: #!/usr/local/bin/php However, here's a quick test to determine if CGI PHP is installed on your server: echo "<? echo 'PHP LIVES!'; ?>" | php If this prints "PHP LIVES!", you have PHP installed on your machine and your just pointing to the wrong place. If the suggestion above does not work, try typing: which php that will return the location of your PHP executable. If the test doesn't work, than you most likely have no access to a CGI version of PHP, or it is not in your execution path. Marco -- ------------ php|architect - The magazine for PHP Professionals The first monthly worldwide magazine dedicated to PHP programmers Check us out on the web at http://www.phparch.com On Fri, 2002-11-15 at 22:52, Scott wrote: > I'm trying to run a simple test php script as a cgi script on my ISP's server > and haven't been able to get it to work, although according them it is > possible. > > I have an example from a book which gives the following steps: > > 1. Put the script in the cgi-bin > 2. run chmod 755 > 3. include "#!/usr/bin/php" at the top. (I have checked that this is the > correct location of php on the server) > > The test script they give looks like this: > > #!/usr/bin/php > > echo "This is a small CGI program." > > Doesn't look like the usual php syntax to me, but I guess this is different. > Anyway I've tried it a bunch of different ways and it hasn't worked and I > haven't been able to find much on the subject from Google. > Can someone tell me where I'm going wrong? > > Thanks, > SW > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php