I'm running RH 9 linux and read some articles on how to run a php script from the shell using the following:

#!/usr/bin/php -q
<?php

print("Hello, world!\n");

?>

I made 100% the path to php was correct and the script file is set as executable but this is what I get:

[root@testsrv5 tests]# ./test.php

Error in argument 1, char 3: option not found
Error in argument 1, char 3: option not found
Usage: php [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}

From this point I tried taking the -q argument out and then I get:

: bad interpreter: No such file or directory

This one is a stumper for me, anyone have any ideas? BTW: I'm using the PHP 4.2.2 RPM that came with RH 9 and my scripts run fine through Apache.

    What do you get when you type
    /usr/bin/php -v
    Directly from the command line? Does it say (cli) or something different? There is a section in the manual on running php from a command line. Might want to look there.

      It just says 4.2.2, nothing else.

        When I run php from the command line (SuSE 8.1, slackware 9.0) i just type: php scriptName.php
        and it all goes just fine, you might want to give that a try.

          Very strange. I would have expected something like:
          /usr/bin/php -v
          PHP 4.3.4 (cli) (built: Nov 13 2003 03:39:03)
          Copyright (c) 1997-2003 The PHP Group
          Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

          Check the compiler options (using phpinfo()) against what the manual says.

            I have a feeling the CLI is not available in version 4.2.2 which I'm running. Unfortunately I'm not a "guru" of compiling and usually use RPM's but the latest RPM is 4.2.2 or else I would upgrade to a newer version.

              Write a Reply...