File exist checking error

Hi all,

I have following code:

export USERID=user
export BATCHHOSTIP=190.113.3.324

remotePath=/home/user
fileName=redbook.txt

EXIST=`ssh $USERID@$BATCHHOSTIP 'if [ -f $remotePath/$fileName ] ; then echo 0; else echo 1 ; fi'`
echo $EXIST

II run the code from other server. The redbook.txt file is exist in /home/user/ in server 190.113.3.324.

I dont know why it print out "1". The program ignore that the file is exist.

Then, I changed my code to:

export USERID=user
export BATCHHOSTIP=190.113.3.324

remotePath=/home/user
fileName=redbook.txt

EXIST=`ssh $USERID@$BATCHHOSTIP 'if [ -e $remotePath/$fileName ] ; then echo 0; else echo 1 ; fi'`
echo $EXIST

It print out "0". But, when I remove the redbook.txt from the location, the program still print out "0". Now, the code ignore the file is not exist.

Anybody have idea what's going on ?

thanks.. :slight_smile:

try putting double " inplace of single quote '