Quantcast
Viewing all articles
Browse latest Browse all 4

Call and run php script from shell script

I'm trying something simple yet can't figured it out. Trying to run one shell script which call php script from the site directory. My shell script is simple test.sh:

#!/bin/sh

LIST="/path/to/my/site/dir"
CONFIG="/usr/bin/php "

for i in $LIST
do
    . "${CONFIG}${i}/test.php"        
done

My test.php doesn't have errors and when I run it directly in browser it's working. It again simple script like

<?php
  // source code
?>

When I run ./test.sh result is

./test.sh: 8: .: Can't open /usr/bin/php /path/to/my/site/dir/test.php

Line 8 is . "${CONFIG}${i}/test.php"

I've tried also to add at the beginning of PHP file this line but the result is same

#!/usr/bin/php

UPDATE: Path to php

$ which -a php
/usr/bin/php

I've also made chmod +x test.php


Viewing all articles
Browse latest Browse all 4

Trending Articles