LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   call a php file (https://www.linuxquestions.org/questions/linux-newbie-8/call-a-php-file-385565/)

petenyce 11-22-2005 02:34 PM

call a php file
 
Im trying to call a php file in a linux bash script is this correct syntax?

#!/bin/bash
/usr/etc/script.php


???

thanks

spooon 11-22-2005 03:18 PM

PHP files are usually not executable (unless you put a shebang on their first line and then give them executable permission); so try "php /usr/etc/script.php". Also, keep in mind that it outputs a complete HTML file including the headers.

CroMagnon 11-22-2005 03:38 PM

If:

the PHP script is marked executable
AND
the first line is a #! line with the path to your PHP binary.

otherwise, you'd be better off specifying the path to the PHP binary and the name of the script on the command line itself.

Code:

#!/bin/bash
PHP=/usr/local/bin/php

$PHP /usr/etc/script.php

Check the man page for any switches you might need to add (depending on the script).

fouldsy 11-23-2005 03:21 AM

You might also need to install php-cgi in order to run PHP scripts from the command line


All times are GMT -5. The time now is 11:01 PM.