ssh 遇到的問題

問題描述:

       當在while循環中,使用ssh執行命令時,之後獲取第一行,例如第一行當IP。

解決方法:

       1. 使用for 循環

       2. 在ssh命令行中加入  -n 參數

 

以下是測試舉例:

#!/bin/bash

cat /tmp/.test.txt   | while  read i
do
ssh -n mysql@$i  -o stricthostkeychecking=no   "md5sum /home/mysql/mysql/etc/my.cnf"
done




#!/bin/bash


for i in `cat /tmp/.test.txt`
do
ssh mysql@$i  -o stricthostkeychecking=no   "md5sum /home/mysql/mysql/etc/my.cnf"
done

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章