Skip to main content
edited tags
Link
derobert
  • 113.3k
  • 20
  • 242
  • 289
deleted 92 characters in body
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

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 postposts 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 1
echo RepCard1=$(expr $(grep -r "sample text" * | wc -l) / 2) >> /usr/local/host1/tempdir/output.properties;

# Server 2

ssh -T user@host2 <<EOF >>/usr/local/host1/tempdir/output.properties;
#alias GetDuplicateCardStats="cd /usr/local/apps/tempdir"
folderPath="cd /usr/local/apps/tempdir";
echo $folderPath;
eval $folderPath;

echo RepCard2=$(expr $(grep -r "sample text" * | wc -l) / 2);
exit
EOF

. /usr/local/host1/tempdir/output.properties;

echo "host 1"
echo $RepCard1

echo "host 2"
echo $RepCard2
# RepCard2 is always executed on Host 1 and print value from host 1

sorry, if itWhat is a repost, but would be really helpful if someone can point the mistake in the above script.

Thanks in advance. Hashmukh?

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 few post 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 1
echo RepCard1=$(expr $(grep -r "sample text" * | wc -l) / 2) >> /usr/local/host1/tempdir/output.properties;

# Server 2

ssh -T user@host2 <<EOF >>/usr/local/host1/tempdir/output.properties;
#alias GetDuplicateCardStats="cd /usr/local/apps/tempdir"
folderPath="cd /usr/local/apps/tempdir";
echo $folderPath;
eval $folderPath;

echo RepCard2=$(expr $(grep -r "sample text" * | wc -l) / 2);
exit
EOF

. /usr/local/host1/tempdir/output.properties;

echo "host 1"
echo $RepCard1

echo "host 2"
echo $RepCard2
# RepCard2 is always executed on Host 1 and print value from host 1

sorry, if it is a repost, but would be really helpful if someone can point the mistake in the above script.

Thanks in advance. Hashmukh

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 1
echo RepCard1=$(expr $(grep -r "sample text" * | wc -l) / 2) >> /usr/local/host1/tempdir/output.properties;

# Server 2

ssh -T user@host2 <<EOF >>/usr/local/host1/tempdir/output.properties;
#alias GetDuplicateCardStats="cd /usr/local/apps/tempdir"
folderPath="cd /usr/local/apps/tempdir";
echo $folderPath;
eval $folderPath;

echo RepCard2=$(expr $(grep -r "sample text" * | wc -l) / 2);
exit
EOF

. /usr/local/host1/tempdir/output.properties;

echo "host 1"
echo $RepCard1

echo "host 2"
echo $RepCard2
# RepCard2 is always executed on Host 1 and print value from host 1

What is the mistake in the above script?

Source Link

SSH over multiple server and save output of multiple commands in file on local server

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 few post 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 1
echo RepCard1=$(expr $(grep -r "sample text" * | wc -l) / 2) >> /usr/local/host1/tempdir/output.properties;

# Server 2

ssh -T user@host2 <<EOF >>/usr/local/host1/tempdir/output.properties;
#alias GetDuplicateCardStats="cd /usr/local/apps/tempdir"
folderPath="cd /usr/local/apps/tempdir";
echo $folderPath;
eval $folderPath;

echo RepCard2=$(expr $(grep -r "sample text" * | wc -l) / 2);
exit
EOF

. /usr/local/host1/tempdir/output.properties;

echo "host 1"
echo $RepCard1

echo "host 2"
echo $RepCard2
# RepCard2 is always executed on Host 1 and print value from host 1

sorry, if it is a repost, but would be really helpful if someone can point the mistake in the above script.

Thanks in advance. Hashmukh