08-12-2009
Help Syntax Shell-Script
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 ...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a rather big script that i have written in ksh and it is falling over in two places with a 'test argument' error. I know this usually means that the if statement is not correct, but it is fine. I have looked through the rest of the script for any odd brackets or ` marks, but can't see... (2 Replies)
Discussion started by: handak9
2 Replies
2. Shell Programming and Scripting
Hi All,
I am new to shell scripting.
I have a variable which holds a numeric value.I have to check whether this variable holds a value between(0- 8),(8-17)(17-24).How do i write this syntax using if in shell scripting.
Thanks
Vignesh (2 Replies)
Discussion started by: vignesh53
2 Replies
3. Shell Programming and Scripting
Hello All,
I looking for a way to verify the correction of shell script syntax.
Is there any switch like -c in perl which do this in shell ?
Thank You. (1 Reply)
Discussion started by: Alalush
1 Replies
4. Shell Programming and Scripting
hello everyone
i am beginner on shell scripting .and i am working on my project work on ad hoc network
i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem "
syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies
5. Emergency UNIX and Linux Support
I want to delete archivelog files that has been archived and applied from primary database
to standby database. This piece of script is working in Linux server. However, I copy it to
Unix server with tiny modification. It won't work and generate the error message. I have checked
code carefullt... (8 Replies)
Discussion started by: duke0001
8 Replies
6. Shell Programming and Scripting
sorry but need help
http://i.investopedia.com/inv/articles/site/CalculationEMA.gif
trying to achieve ema
in script I have this syntax which errors
ema=` ;
the 0.153846154 ='s Smoothing Factor
really appreciate help (3 Replies)
Discussion started by: harte
3 Replies
7. Shell Programming and Scripting
I am trying to run a unix script in my home directory.Snippet below
echo "`date '+%Y%m%d_%H%M%S'` Getting ProductList.dat"
if ( -f $DIR/ProductList.dat) then
cp $DIR/ProductList.dat MigratedProductList.dat
else
echo "`date '+%Y%m%d_%H%M%S'`ProductList.dat does not exist; Processing... (4 Replies)
Discussion started by: Mary James
4 Replies
8. Shell Programming and Scripting
I am creating a shell script. In which, I need to get server name and server IP. I used this command in script.
servername=`cat /etc/hosts|grep `eval hostname`|awk '{print $2}'`
however, when execute script or put set -x to debug, it return:
line 13: syntax error at line 13: `|' unexpected... (4 Replies)
Discussion started by: duke0001
4 Replies
9. Shell Programming and Scripting
Hi Everyone,
Is there any way ( generic) to check syntax of Shell Scripts without running it?? (4 Replies)
Discussion started by: roy121
4 Replies
10. Shell Programming and Scripting
I want to make the file test condition a variable ($Prmshn in code below).
My goal is to use something like the first three unsuccessful if statetments since the 'if
#!/bin/ksh
test_input()
{
Prmshn=${1}
InFLNm=${2}
ifReq="-$Prmshn $InFLNm"
#the following three if statments fail:
#if ] ;... (10 Replies)
Discussion started by: ms63707
10 Replies
LEARN ABOUT MOJAVE
plutil
PLUTIL(1) BSD General Commands Manual PLUTIL(1)
NAME
plutil -- property list utility
SYNOPSIS
plutil [command_option] [other_options] file
...
DESCRIPTION
plutil can be used to check the syntax of property list files, or convert a plist file from one format to another. Specifying - as an input
file reads from stdin.
The first argument indicates the operation to perform, one of:
-help Show the usage information for the command and exit.
-p Print the property list in a human-readable fashion. The output format is not stable and not designed for machine parsing. The
purpose of this command is to be able to easily read the contents of a plist file, no matter what format it is in.
-lint Check the named property list files for syntax errors. This is the default command option if none is specified.
-convert fmt Convert the named file to the indicated format and write back to the file system. If the file can't be loaded due to invalid
syntax, the operation fails.
fmt is one of: xml1, for version 1 of the XML plist format binary1, for version 1 of the binary plist format json, for the
JSON format
There are a few additional options:
-- Specifies that all further arguments are file names
-s Don't print anything on success.
-r For JSON, add whitespace and indentation to make the output more human-readable.
-o path Specify an alternate path name for the result of the -convert operation; this option is only useful with a single file to be
converted. Specifying - as the path outputs to stdout.
-e extension Specify an alternate extension for converted files, and the output file names are otherwise the same.
DIAGNOSTICS
The plutil command exits 0 on success, and 1 on failure.
SEE ALSO
plist(5)
STANDARDS
The plutil command obeys no one's rules but its own.
HISTORY
The plutil command first appeared in Mac OS X 10.2.
Mac OS X August 30, 2002 Mac OS X