I want to SSH over multiple server (host 1, host2 and host 3) and save output of multiple commands (cmd1, cmd2 etc) in file (output.properties) on local server. I know there are a few posts similar to this, but I a not sure where I am going wrong. Below is the code snippet.folderPath=cd /usr/local/apps/tempdir;echo $folderPath;eval $folderPath;# host 1echo RepCard1=$(expr $(grep -r sample text * | wc -l) / 2) >> /usr/local/host1/tempdir/output.properties;# Server 2ssh -T user@host2 <<EOF >>/usr/local/host1/tempdir/output.properties;#alias GetDuplicateCardStats=cd /usr/local/apps/tempdirfolderPath=cd /usr/local/apps/tempdir;echo $folderPath;eval $folderPath;echo RepCard2=$(expr $(grep -r sample text * | wc -l) / 2);exitEOF. /usr/local/host1/tempdir/output.properties;echo host 1echo $RepCard1echo host 2echo $RepCard2# RepCard2 is always executed on Host 1 and print value from host 1What is the mistake in the above script?
SSH over multiple server and save output of multiple commands in file on local server
shell script;ssh