Bash Shell PHP Script Status
| From: | Rankin, Randy | Date: | Fri, 11 Apr 2003 13:56:49 +0000 |
| Subject: | Bash Shell PHP Script Status | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-143497@lists.php.net to get a copy of this message | ||
I need some help. The clip of the bash script below reads a directory full
of files and then calls a php script for each file that parses an xml file
and inserts some data into a database. I am unsure how to get the status
of the of the php script so I can check for xml parse errors or database
insert errors in the php script before continuing with the next file. Will
the php script return any codes to the shell, and If so how do I capture
them? Error checking is performed in the php script. I would like to have
an if statement right below the script that checks the return codes from the
php script.
example of what I think I need: if [return_code==0] # where do I get
the codes from the script, error are produced in the php file when they
exist.
then
move my files around
else
write an error and move to the next
files
fi
Here is the clip of the bash script that is run by cron.
if [ -e "$semaphore" ]
then
process_dir=/opt/pipechain/CS01/snd/process
cp $i $process_dir/process.dat
/usr/local/bin/cs01_inbound.sh # this is where I
call the script. If the script completes success I want to continue.
### if statement goes here I believe
#move the .sem file to the tmp directory
tmp_dir=/opt/pipechain/CS01/tmp
echo "Semaphore File Exist--> Processing $i"
mv $semaphore $tmp_dir/$semaphore
echo "This is the Sem --> $semaphore file"
inp_dir=/opt/pipechain/CS01/inp
dat_file=$semfile.dat
echo "This is the data --> $dat_file file"
mv $dat_file $inp_dir/$dat_file
else
echo "No semaphore file exist for $i"
fi