It is currently Tue, 07 Dec 2021 02:56:42 GMT



 
Author Message
 help converting csh script to ksh?
 Hello. I would like to convert the following working
CSH script to the KORN shell. Any help is appreciated.

I simply want to run a command on files that match 5v*.dat, only if the
file "go" exists and the one with the .stat extension does not exits.

for FILE in 5v*.dat
do
  if ( -e go && ! -e $FILE.stat ) then
    sdb $FILE -v
  fi
done

Here is the error I get:
                -e: ./loader.ksh 6: not found

--
--------------------------------------------------
Mark Fearer                        *   C:\DOS
mfea...@mail.fearernet.com         *   C:\DOS\RUN
http://www.**-**.com/ ; *   RUN\DOS\RUN



 Tue, 05 Mar 2002 03:00:00 GMT   
 help converting csh script to ksh?
In article <7ruf3l$bi...@pyrite.mv.net>,

This is not a working csh script to begin with.  for/do/done is ksh syntax,
not csh syntax.  It looks like you've converted the for-loop to ksh, but
left the if partially in csh syntax (I say partially because you end it
with ksh's "fi" rather than csh's "endif").

So I suppose what you're really asking about is the "if" command and the
test expression.  It should be:

if [[ -e go && -e $FILE.stat ]]; then
  sdb $FILE -v
fi

You can also write it as:

if [ -e go -a -e $FILE.stat ]; then
  sdb $FILE -v
fi

and it will be backward compatible to Bourne shell.

BTW, you should use "$FILE" rather than just $FILE, in case any of the
matching files have spaces in their names.

--
Barry Margolin, bar...@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



 Tue, 05 Mar 2002 03:00:00 GMT   
 
   [ 2 post ] 

Similar Threads

1. Converting ksh scripts to csh scripts

2. converting csh script to ksh

3. Converting a csh script to ksh??

4. help in learning how to do Bourne shell scripts then converting them to csh scripts

5. need help converting sh scripts to csh scripts

6. Help to convert ksh function to tcsh or csh

7. Need Help Converting csh stuff to ksh

8. help converting CSH shell scripts

9. Sourcing a csh script from a ksh script

10. csh scripts inside ksh script?


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software