Entry
Why doesn't my PHP shell script work?
Why will only print and echo work in my shell script?
Jun 23rd, 2002 16:27
Damien Bonvillain, Philip Olson, Ben Munoz, Nathan Wallace,
You may have forgotten the #!/path/to/php.binary at the top... Mainly
because echo "some text" is valid shell script, but the other stuff
isn't...
One common mistake is that you use DOS-like newlines in your script
instead of UNIX newlines.
Also check that you are using the CGI Version of PHP. If you are, then
you should be able to execute any PHP Script (minus ones with functions
that are apache-specific like the virtual() function) as-is without a
problem... i.e.
myshellscript.php
#!/usr/local/bin/php -q
<?php
// my code
?>
A few shell tutorials exists, here are a couple :
Using PHP As A Shell Scripting Language :
------------------------------------------------------------------
http://phpbuilder.com/columns/darrell20000319.php3
PHP Shell Scripting :
------------------------------------------------------------------
http://miester.org/simple_boards/threads.php/topicID,7/category,3]
Btw, one way to find the location of the PHP binary in linux is by
typing the following in bash/telnet :
which php