myvariable=$(/usr/bin/php -f $HOME/lib/get_fifobuild.php)
Assign the output from your php script to a variable called "myvariable".
Update
This will assign the output of the command to a variable, but since you still have problems, I can suggest a few things:
you have get_builds.php and get_fifobuild.php elsewhere.
check if $ HOME is installed correctly. You may be better off with a different variable name here, since this environment variable is usually set to your home directory. This, however, is unlikely to be a problem, as you get the output from the script.
Is the text that you provided the exact contents of your PHP file? If you have quotes around phpinfo()
, for example, this will result in the output being just the string "phpinfo ()". In fact, you don't need echo
at all, and it can do the contents of your PHP file as follows.
get_fifobuild.php:
<?php phpinfo(); ?>
Update 2:
Try changing the script to:
#!/bin/bash HOME=`dirname $0`; log(){ NEW_LOG=$HOME/logs/cloud-`date +%d_%m_%Y`.log echo "$1" >> $NEW_LOG } log "Date: `date`"; data=$(/usr/bin/php -f $HOME/lib/show.php); log "$data";
Basically adding double quotes around variables in the lines 'log' and 'echo'. The problem you ran into was that only the first line of your php output was written.
source share