I am trying to run a unix script in my home directory.Snippet below
echo "`date '+%Y%m%d_%H%M%S'` Getting ProductList.dat"
if ( -f $DIR/ProductList.dat) then
cp $DIR/ProductList.dat MigratedProductList.dat
else
echo "`date '+%Y%m%d_%H%M%S'`ProductList.dat does not exist; Processing Terminated"
echo "***************************************************************************"
exit 1
endif
It gives me error like
1. syntax error at line 31 : `else' unmatched
2. -f: not found
3. /ProductList.dat: not found(ProductList.dat is already present in the specified location)
My entire script runs fine in another user account.Will there be any difference for the command and syntax if we run in our home directory
-f option is for checking file, whether its ordinary or not.
What exactly you want to check? only the existence, then try -r option, you can copy that.
echo "`date '+%Y%m%d_%H%M%S'` Getting ProductList.dat"
if [ -f $DIR/ProductList.dat ]; then
cp $DIR/ProductList.dat $TARGET_DIR/MigratedProductList.dat
else
echo "`date '+%Y%m%d_%H%M%S'`ProductList.dat does not exist; Processing Terminated"
echo "***************************************************************************"
exit 1
fi