asehgal asehgal - 4 months ago 11
PHP Question

php script does not run when called from bash script on MAC OS X

Following is a bash script

run.command
that I am trying to use to call a PHP script

#!/bin/bash
#!/usr/bin/php
# Main script

php -f generateTest.php


Why does this not run when I "double click" the bash script ? It runs on calling from the
terminal
on OS X

I get the error message

asehgal-MacBook-Pro:~ asehgal$ /Users/asehgal/projects/configtest/run.command ; exit;
Could not open input file: generateTest.php
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.


I have used
chmod +x
to make it executable.

Answer

Use the absolute path to your generateTest.php file and it should work, it's not working now because it's trying to find generateTest.php in your current working directory (where you are running run.command from)

Example:

#!/bin/bash
#!/usr/bin/php
# Main script 

php -f /Users/asehgal/projects/configtest/generateTest.php
Comments