0
if 
[ -d patch/tempatch ];
then;
cd patch/tempatch/;

for i in `ls`;
do;
tar -xvf $i;
rm -f $i;
done;

for i in `ls`;
do;
cd $i;
cp -R files/* patch/SP02JUL11/files/;
cd ..;
rm -Rf $i;
done;

else;
echo "directory not found";
fi

All the commands in single line by separating with ";"

While executing it throws 0403-057 Syntax error: ; is not expected

can anyone help on this ?

Thank you

Abhineet
  • 5,320
  • 1
  • 25
  • 43
user3468019
  • 3
  • 1
  • 1
  • 2

1 Answers1

1

It's not specified which shell is interpereting this script... From error code I assume it's ksh...

From the error message, I presume that the problem is that after then, else, do, ksh does not accept a ;.

However, just out of curiosity, I did just install ksh on my linux box. It's at version "93u+ 2012-08-01". Your script runs just fine, no syntax errors, here... Probably you are running a different (possibly older) version of the shell, or a different shell at all... You should definitely specify which shell you're using... :-).

MarcoS
  • 17,323
  • 24
  • 96
  • 174
  • i am using ksh shell only – user3468019 Mar 27 '14 at 11:19
  • os Red Hat Enterprise Linux Server release 6.3 (Santiago) – user3468019 Mar 27 '14 at 11:20
  • It's quite strange, I'm on a Centos Release 6.5... However, if you enter each command on a different line (as I see from your code), you can avoid semicolons at all... Semicolons are intended to separate commands on the same line... In particular they are *requested* before a `do`, a `then`, an `else`, but they are *forbidden* after the same commands... I would say ksh (but bash too) is quite 'choosy'... :-) – MarcoS Mar 27 '14 at 13:24