cp: cannot stat `/opt/IBM/cofig.sh': No such file or directory

Hi all,
I'm trying to write a single line command to do this

  1. ssh user@hostA
  2. Check whether the dir /opt/IBM/ exists
  3. copy -a /opt/IBM/config.sh /opt/IBM/config.sh.old

This is the command

ssh -v user@hostA "test -d /opt/IBM" && cp -a /opt/IBM/config.sh /opt/IBM/config.sh.old || echo " Failed"

It fails with the following error:

cp: cannot stat `/opt/IBM/config.sh': No such file or directory
Failed

The directory exists on hostA and the file too, but I'm getting this error.
Any ideas pls? or any other way to do this in a single line command ?

uname:
Linux hostA 2.4.21-53.ELsmp #1

Thanks,
Chanti

Remove all embedded ticks so entire command line passed to hostA is in double quotes and better test for file existence instead of directory.

ssh -v user@hostA "test -f /opt/IBM/config.sh && cp -a /opt/IBM/config.sh /opt/IBM/config.sh.old || echo Failed"

Thank you!!
it worked.

You should test for existence of the file you want to copy instead of the directory that contains it, just as Shamrock proposed.
But what is the -a in the copy command good for if you only copy a single file?
Besides, should the remote host be an AIX, as the /opt/IBM might suggest,
I doubt that its cp knows this recursive, preserve switch.