#!/bin/sh # PHP_ExtractDefine.sh # Mon Mar 9 23:59:18 GMT 2009 # Chieh Cheng # http://www.CynosureX.com/ # GNU General Public License (GPL) Version 2, June 1991 scriptName=`basename "$0"` usage () { echo " Usage: ${scriptName} \"PHP file\" \"define\"" } if [ $# -eq 2 ] then phpFile="$1" define="$2" # Noticed that with PHP 5.2.9, shell environment current # directory is not applied to PHP. PHP 5.2.6 does not # have this problem. So we specify the current directory # for the temporary PHP script file below. tempFile=`GetTempPathName.ksh "${scriptName}" ".tmp.php" "."` echo " "${tempFile}" echo " require_once ('${phpFile}');" >> "${tempFile}" echo " echo ${define};" >> "${tempFile}" echo "?>" >> "${tempFile}" value=`php -q "${tempFile}"` rm "${tempFile}" echo "${value}" else usage fi