Reputation: 11
I am new to shell scripting , I am trying to run the following command from shell script .
diff <(ssh user@remote_host 'cat remote_file.txt') <(ssh user2@remote_host2 'cat remote_file2.txt')
but getting an error :
./a.sh: syntax error at line 1: `(' unexpected
I tried some example trough googleing which says to use $() around the code , but it did not work can any one please help me with this .
Upvotes: 1
Views: 206
Reputation: 101
I just make this bash script without problems
#!/bin/bash
diff <(ssh user@remote_host cat remote_file.txt) <(ssh user2@remote_host2 cat remote_file2.txt)
exit 0
this work with the next conditions:
-remote_host and remote_host2 stay in the list of ~/.ssh/known_hosts
-user and user2 exists and have permissions
-remote_host and remote_host2 are operative and have ssh server on
-user@remote_host and user2@remote_host2 have configured ssh for work without passwords
if you not know how do this see http://www.linuxproblem.org/art_9.html
maybe your error stay in '
but it must work well if you don't use 'remote_file.txt'
and only use remote_file.txt
Upvotes: 0
Reputation: 201
I understand you want to use the output from the two remote files in a 'diff'. There are many things wrong in your solution:
What I would do (to accomplish what I think you want to do) is turn it into three seperate commands:
ssh user@remote_host 'cat remote_file.txt' > file1
ssh user2@remote_host2 'cat remote_file.txt' > file2
diff file1 file2
Upvotes: 2