2016-07-14 35 views
-2

我有這40臺服務器,我需要測試這個命令:極品循環命令是bash

ssh -qt [email protected] 'hostname' 

我有server1X高達server40X在這裏,我不想重複手動所有的命令,可以你與我分享任何循環命令用於Linux盒?喜歡我..還是?

回答

0
#!/bin/bash 
for i in `seq 1 40`; 
do 
    ssh -qt [email protected]${i}X 'hostname' 
done 
+2

'server $ iX'將嘗試並且無法展開名爲'$ iX'的變量。它需要是'server $ {i} X'。 –

+0

謝謝馬丁!我在{} 1..40作出 你的建議的腳本 '#!/斌/慶典 SVR =服務器 一些捷徑,因爲我做 SSH -qt用戶@ $ SVR我 「X」 '主機' done' –

0

使用此

for i in {1..40}:; do ssh -qt [email protected]${i}X 'hostname'; done 
+0

'服務器$ iX'將嘗試和失敗,以擴大名爲'$ iX'變量。它需要是'server $ {i} X'。 –

+0

@Keith我剛剛意識到它..謝謝!修正了它 –

+0

謝謝Jesintha! –