从bash脚本执行php脚本

First I tried other questions that may lead to an answer but failed. Anyway I have a problem executing a php script from a bash script and outputs the following error message: Could not open input file: /root/dir/file.php, I can execute the php script fine from terminal however I tried using the 2 following codes in the shell script to execute the php script:

wordpress="/etc/alternatives/php /root/dir"
$wordpress/file.php $input

and

php /root/dir/file.php

and they both failed, any help appreciated.

I'm guessing that your /root/dir means doc root. The kernel knows nothing about apache root dirs so does not know where to go. In the bash script you a) do not need to use a path to php, it is already registered b) you do need to use the absolute path to the script, unless it is in a directory that is listed in the PATH variable ( you can use a symlink asd well of course)

So try

php /absolute/path/to/script.php