I need to transfer a file from source to destination (different systems with different IPs) using "scp" command and before transfer the file i have to check the file is available in destination or not, if it is there no need to transfer, otherwise we have to transfer.
you should be careful whether the command : ssh user@host "test -e $FILE" returns 0 for successful execution of ssh command or successful test of the file exists. check your SSH manual for any such indications.
$ ssh host1 'test -e /etc/resolv.conf' ; echo $?
0
$ ssh host1 'test -e /etc/resolv.confa' ; echo $?
1
$ ssh host1a 'test -e /etc/resolv.conf' ; echo $?
ssh: host1a: Name or service not known
255
$ ssh host1a 'test -e /etc/resolv.confa' ; echo $?
ssh: host1a: Name or service not known
255
$ ssh user@host2 'test -e /etc/resolv.conf' ; echo $?
ksh: test: argument expected
1
$ ssh user@host2 'test -f /etc/resolv.conf' ; echo $?
0
$ ssh user@host2 'test -f /etc/resolv.confa' ; echo $?
1
OpenSSH always passes back the return code of the command, your only problem might be if the command returns 255, since that would make it difficult to discern between an SSH error and an application error.
Maybe your hosts' test command doesn't know about the -e switch. Use -f instead (which doesn't check for existence but whether it's a file or not. Will fail on directories)