sh: syntax error: `...' unexpected???

Hello all,

I want to create a script that polls every hour a directory for the existence of a file. The file I look for is a `token` dropped by an external process at the completion of a successful FTP process. I wrote this script `checkfile.ksh`:

#!/usr/bin/ksh

if [[ -e $HOME/tokenfile ]] then
mailx -s "Token file found! Data files received!" email_address < $HOME/emptyfile
fi
exit

To test it, I touched a file (`tokenfile`) in my $HOME directory, ran my script and got this error

sh: syntax error at line ...: `$HOME/core' unexpected

I declared the file name as a variable
: ${COREFILE:=/$HOME/tokenfile}... [[ -e $COREFILE ]] but got the same error

sh: syntax error at line ...: `$HOME/COREFILE' unexpected

What the @!*%%# (sorry!) am I missing here?? I run this script as the owner of the directory, I have the default `umask` value (not sure if it matters) and I run HP-UX B11.11.

Any help is welcome. I feel like the solution is here: I am just not seeing it.

TIA!!!

Al.

There is no -e. Maybe you want -a or something.

And "then" has to be on a separate line or preceeded with a semi-colon.

Okay. It works if I use "-a" instead of "-e". Thanks for the help.

Using "-e" only works on versions of KSH never than the 11/16/88f version.

This is also the version I run...

Again, thank you.

Now, I have to go kick myself...

Al.

ksh seems to tolerate the absence of the semicolon providing that you use the double brace version of the test construct. I have tested this on HP-UX 11.11.

Try using -f which is TRUE if the file exists and is a regular file or -s which is TRUE if the file exists and has a size greater than zero.