This question is a bit complicated. I will try to explain in detail.
I have two machines, one is local and other say 192.168.1.2
. I have set the following variables in my local machine
CHECK="/home/test/Desktop/"
There exists a user named test
in both my local machine as well as remote machine. I want to run the following command from my local over ssh.
ssh -n [email protected] "until [ `cat $CHECK/samplefile | grep "string"` ]; do touch $CHECK/success; done"
What I am trying to achieve is, I want to check the $CHECK/samplefile for the entry named "string" in my remote machine. Once it is found I want to exit the until
loop and go further. But when I run this command I get the following error message.
cat: /home/test/Desktop//samplefile: No such file or directory
But I am pretty sure that my remote machine contain file name samplefile in test
user's Desktop. On a further research I came to know that the conditional statement of until
given in backquotes actually run at local
instead of remote
(My local doesn't contain such a file in Desktop). Also, the rest of the commands inside until loop works fine and a new file named success is created in remote machine's Desktop.
I am not sure whether the issue is with backquotes or until. I have been stuck on this for the past 3 hours. Any suggestions?