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 .
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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.