![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| 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 11:16 AM |
| syntax error at line 59: `end of file' unexpected | Remi | SUN Solaris | 4 | 01-16-2007 02:48 PM |
| sh: syntax error: `...' unexpected??? | alan | Shell Programming and Scripting | 5 | 06-22-2004 07:58 PM |
| sh: syntax error at line 1: `>' unexpected | atiato | High Level Programming | 2 | 03-16-2004 07:39 AM |
| syntax error: `(' unexpected | adadevil | UNIX for Dummies Questions & Answers | 11 | 12-14-2001 09:17 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Dear all,
When I tried to run receive.sh,it returned following errors. syntax error near unexpected token `do Code:
#!/usr/bin/ksh
GlobalValueReceive=r
GlobalValueWorking=w
GlobalValueTemp=t
$exec 0<Property
while read LineInProperty
do
if [ ${LineInProperty:0:11} = New_receive ]
then
$GlobalValueReceive = ${LineInProperty:25}
fi
if [ ${LineInProperty:0:11} = New_working ]
then
$GlobalValueWorking = ${LineInProperty:25}
fi
if [ ${LineInProperty:0:8} = New_temp ]
then
$GlobalValueTemp = ${LineInProperty:22}
fi
done
(($#<2)) && { print "2 parameters: \n p_seq_no\n p_sys_ind"; exit 1; }
typeset -i pass_check
typeset -i p_seq_id
p_seq_id=$1
p_sys_ind=$2
pass_check=0
# file's count
check_count=`ls -l ${GlobalValueReceive}/${p_sys_ind}.Witness*|grep "^-"|wc -l`
print ${check_count} seq files
for i in $(ls ${GlobalValueReceive}/${p_sys_ind}.Witness*)
do
seq_id=${i##*Witness.}
seq_id=${seq_id%%.*}
mv ${GlobalValueReceive}/${p_sys_ind}.*.${seq_id}.* ${GlobalValueTemp}/dos/
done
for i in $(ls ${GlobalValueTemp}/dos/*)
do
#dos2ux ${i} > ${GlobalValueTemp}/dos2/${i##${GlobalValueTemp}/dos/}
cat ${i} > ${GlobalValueTemp}/dos2/${i##${GlobalValueTemp}/dos/}
cat ${GlobalValueTemp}/dos2/${i##${GlobalValueTemp}/dos/} | tr -d "
" > ${GlobalValueTemp}/${i##${GlobalValueTemp}/dos/}
rm ${i}
done
print files have been moved to temp folder
for i in $(ls ${GlobalValueTemp}/${p_sys_ind}.Witness*)
do
print begin to check the files with seq_id ${p_seq_id}
if [ ${p_sys_ind} = 111111 ]
then
/home/bodi/bin/ef_validate.sh ${p_seq_id}
else
/home/bodi/bin/mp_validate.sh ${p_seq_id}
fi
return_code=$?
if [ ${return_code} = 0 ]
then
print file with seq_id ${p_seq_id} passed!
mv ${GlobalValueTemp}/${p_sys_ind}.*.${p_seq_id}.* $GlobalValueWorking/
mv $GlobalValueWorking/${p_sys_ind}.Witness.${p_seq_id}.*.txt $GlobalValueWorking/${p_sys_ind}.Witness.${p_seq_id}.txt
pass_check=${pass_check}+1
p_seq_id=${p_seq_id}+1
else
print file with seq_id ${p_seq_id} failed!
for j in $(ls ${GlobalValueTemp}/${p_sys_ind}.*.${p_seq_id}.*)
do
mv ${j} ${GlobalValueWorking}/${return_code}.${j##${GlobalValueTemp}/}.rej
done
for j in $(ls ${GlobalValueTemp}/${p_sys_ind}.*)
do
mv ${j} ${GlobalValueWorking}/1.${j##${GlobalValueTemp}/}.rej
done
break
fi
done
print quit with ${pass_check} passed check
exit ${pass_check}
Appreciate to any helper. Thanks. |
|
||||
|
Quote:
Sorry for any misreading ,did you mean that I should modify the code like following? Quote:
Dear Mr.Jean,I just touched the Korn shell script several days,thank you so much for your assistance. Regards, Joshua.Duan |
|
||||
|
No he meant:
set -x exec 0<Property while read LineInProperty do if [ ${LineInProperty:0:11} = New_receive ] then GlobalValueReceive={LineInProperty:25} fi if [ {LineInProperty:0:11} = New_working ] then GlobalValueWorking={LineInProperty:25} fi if [ ${LineInProperty:0:8} = New_temp ] then GlobalValueTemp={LineInProperty:22} fi done |
|
||||
|
Still had problem
Hi,I've corrected the code as above.The file ran normally,but it had a error prompt: :invalid option line 2 : set: -2 (the snap shot is in the attachment.)
I can't remove set -x,or the code won't run.What shall I do? Code:
#!/usr/bin/ksh
set -x
GlobalValueWorking=w
exec 0<Property
while read LineInProperty
do
if [ ${LineInProperty:0:11} = New_working ]
then
GlobalValueWorking={LineInProperty:25}
fi
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|