![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| awk Shell Script error : "Syntax Error : `Split' unexpected | Herry | UNIX for Dummies Questions & Answers | 2 | 03-17-2008 08:16 AM |
| "syntax error at line 21 :'done' unexpected." error message" | ibroxy | Shell Programming and Scripting | 3 | 08-08-2007 03:45 AM |
| Syntax error in script | KindHead | Shell Programming and Scripting | 2 | 12-12-2006 07:28 PM |
| syntax error in script !! | uuser | Shell Programming and Scripting | 13 | 02-15-2006 11:58 AM |
| Syntax error in a script... | rajus19 | Shell Programming and Scripting | 8 | 12-07-2005 12:20 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
problem with script and syntax error message
Hi I have the following script and have problem debugging the problems. The function of this script is to make sure the entire file is being received (the filesize of a data is not changing after 20 seconds) and start moving the file to another directory. This script should be started every 30mins.
Code:
#!/usr/bin/ksh
. /opt/Modules/init/ksh
SF_BASAR=/opt/bs/sf
UMC_MASK=/home/umc/dropbox/test
FLAGLIST=/home/umc/dropbox/test/flaglist
FILELIST=/home/umc/dropbox/test/filelist
DIRECTORY=/home/umc/dropbox/datacentre
#store the name of files in bs/sf to filelist
ls -l $SF_BASAR | nawk '{print $9}' > $FILELIST
#compare flag in flaglist with items in $SF_BASAR
#delete flag in flaglist that are not in $SF_BASAR
egrep "$(<$FILELIST)" $FLAGLIST > flaglist.tmp
mv -f flaglist.tmp $FLAGLIST
#if there is an flag in flaglist,exit
NO_OF_FILES=ls /opt/bs/sf/*.gds* | wc -w | nawk '{print $1}'
if (`ls -l $FLAGLIST | nawk `{print $5}'' != "0") then
exit 1
else
if ($NO_OF FILES != "0") then
for i in `ls $SF_BASAR/*.gds*` do
filesize1=`ls -l $i | nawk `{print $5}''
sleep 20
filesize2=`ls -l $i | nawk `{print $5}''
if $filesize1=$filesize2 then
#move the file
mv i $UMC_MASK
#create flag in flaglist
echo $i >> FLAGLIST
fi
done
fi
fi
Code:
script: /opt/bs/sf/file1.gds.gdz.gpg: cannot execute
0
script[23]: syntax error at line 29 : `filesize1=`ls -l $i | nawk `{print' unexpected
|
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Try this :
Code:
#!/usr/bin/ksh
. /opt/Modules/init/ksh
SF_BASAR=/opt/bs/sf
UMC_MASK=/home/umc/dropbox/test
FLAGLIST=/home/umc/dropbox/test/flaglist
FILELIST=/home/umc/dropbox/test/filelist
DIRECTORY=/home/umc/dropbox/datacentre
#store the name of files in bs/sf to filelist
ls -l $SF_BASAR | nawk '{print $9}' > $FILELIST
#compare flag in flaglist with items in $SF_BASAR
#delete flag in flaglist that are not in $SF_BASAR
egrep "$(<$FILELIST)" $FLAGLIST > flaglist.tmp
mv -f flaglist.tmp $FLAGLIST
#if there is an flag in flaglist,exit
NO_OF_FILES=` ls /opt/bs/sf/*.gds* | wc -w | nawk '{print $1}'`
if (`ls -l $FLAGLIST | nawk '{print $5}'` != "0")
then
exit 1
else
if ($NO_OF FILES != "0") then
for i in `ls $SF_BASAR/*.gds*`
do
filesize1=`ls -l $i | nawk '{print $5}'`
sleep 20
filesize2=`ls -l $i | nawk '{print $5}'`
if $filesize1=$filesize2
then
#move the file
mv i $UMC_MASK
#create flag in flaglist
echo $i >> FLAGLIST
fi
done
fi
fi
|
|
#3
|
|||
|
|||
|
the following command should be in either back quotes or $(..)
we can't directly assign the like this the command ouput Code:
NO_OF_FILES=`ls /opt/bs/sf/*.gds* | wc -w | nawk '{print $1}'`
Code:
if (`ls -l $FLAGLIST | nawk `{print $5}'' != "0") then
same thing here again... Code:
filesize1=`ls -l $i | nawk `{print $5}''
check full code again for this kind of errors... |
|
#4
|
|||
|
|||
|
I have changed the script and it look like this now:
Code:
#!/usr/bin/ksh
. /opt/Modules/init/ksh
SF_BASAR=/opt/basar/silicon_foundry
UMC_MASK=/home/umc/dropbox/test
FLAGLIST=/home/umc/dropbox/test/flaglist
FILELIST=/home/umc/dropbox/test/filelist
DIRECTORY=/home/umc/dropbox/datacentre
#store the name of files in basar/silicon foundry to filelist
ls -l $SF_BASAR | nawk '{print $9}' > $FILELIST
#compare flag in flaglist with items in $SF_BASAR
#delete flag in flaglist that are not in $SF_BASAR
egrep "$(<$FILELIST)" $FLAGLIST > flaglist.tmp
#alternative: fgrep -f $FILELIST $FLAGLIST > flaglist.tmp
#alternative: grep -F $FILELIST $FLAGLIST > flaglist.tmp
mv -f flaglist.tmp $FLAGLIST
#if there is an flag in flaglist,exit
NO_OF_FILES='ls /opt/basar/silicon_foundry/*.gds* | wc -w | nawk `{print $1}`'
#alternative: FLAGLIST_CONTENTS='wc -l $FLAGLIST'
if (`ls -l $FLAGLIST | nawk '{print $5}'` != "0") then
exit 1
else
# if `ls $SF_BASAR/*.gds*`<>"" then
if ($NO_OF FILES != "0") then
for i in `ls $SF_BASAR/*.gds*` do
filesize1='ls -l $i | nawk `{print $5}`'
sleep 20
filesize2='ls -l $i | nawk `{print $5}`'
if $filesize1=$filesize2 then
#move the file
mv i $UMC_MASK
#create flag in flaglist
echo $i >> FLAGLIST
fi
done
fi
fi
syntax error at line 31 : `filesize1="ls -l $i | nawk `{print $5}`"' unexpected |
|
#5
|
|||
|
|||
|
the line should be
filesize1=`ls -l $i | nawk '{print $5}'` could you please check both the postings made by my self and another friend... you have used the quotes wrongly.. interchanged... better to use the full code provided by aigles, so that you won't make any mistake... |
|
#6
|
||||
|
||||
|
I liked the quote
"and have problem debugging the problems" :P
__________________
War doesnt determine who is right, it determines who is left |
||||
| Google The UNIX and Linux Forums |