Hi Guys,
i�ve a question ... but it�s a litte bit tricky:
i�ve a 3 php-scripts which run�s via cron at night. These script reads an xml-file a writes it in an MySQL-DB.
I named them (for example here ) Script1 - Script3. The XML-Files i named xml1 - xml3.
Now, i�ve build a Batch-file, which will start the php-scripts an should write success or error to a log-file ...
And here�s my problem:
When Script1 starts, it reads xml1 - when xml1 is alright, script1 runs till the end and there�s no output - "echo $?" returns with "0"
Now, (error-example) when Script1 starts, it reads xml1 - when xml1 is missing or corrupt, script1 runs till the end too and there�s an output called "Can /srv/www/htdocs/_source/xml-file not read."
This is an order at the end of script1 (and script 2 & 3 of course)
When i type "echo $?" it returns "0", too.
And here�s my second problem:
my logfile should looks like this:
"Script1 was read - success" (-> when script1 ends with no errors, xml-is fine)
"Script1 was read - error" - Can /srv/www/htdocs/_source/xml-file not read." (-> when script1 ends with errors.)
Can somebody help me with the syntax to write my batch-file:
Here�s are my first steps/trials ...
#! /bin/sh
# Description
cd /srv/www/htdocs/import (here are the 3 scripts)
/usr/bin/php5 script1.php;
if [ $ ... don�t know]
then
echo ' Script1 was read - success' ;
else
echo ' Script1 was read - error' - Can /srv/www/htdocs/ ... ' ;
fi;
... and so on till Script3
Many Thanks.
Regards,
Michael
PS:
Hope, my explanations are plausible. If not, feel free to ask ...