脚本1
for machine in host name; do
ssh user@$machine /bin/bash << EOF
uname -a
lscpu | grep "^CPU(s)"
grep -i memtotal /proc/meminfo
EOF
done
脚本2
for machine in Host Name; do
ssh user@$machine /bin/bash<<< 'lshw;cat /etc/resolv.conf'
done
我有这两个单独的脚本,如何将这个脚本作为一个加入
答案1
这是期望的结果:
for machine in host name; do
ssh user@$machine /bin/bash << EOF
uname -a
lscpu | grep "^CPU(s)"
grep -i memtotal /proc/meminfo
lshw
cat /etc/resolv.conf'
EOF
done
正如评论中所建议的,您需要在内联分隔符之间添加第二个脚本中的远程命令(EOF
在您的情况下)