簡體   English   中英

我想使用parallel-ssh在多個服務器上運行bash腳本,但它只是打印echo語句

[英]I want to use parallel-ssh to run a bash script on multiple servers, but it simple prints the echo statements

我有一個名為sr_run_batch.sh的bash腳本,它可以實現圖像的超分辨率。 現在我想同時在不同的服務器上進行並行測試。 即。 1在一個給定時間點的虛擬機。 然后在一個時間點,3個然后4個虛擬機。我嘗試寫入命令

for host in $(cat hosts.txt); do ssh "$host" "$command" >"output.$host"; done 
ssh-keygen && for host in $(cat hosts.txt); do ssh-copy-id $host; done

文件hosts.txt包含服務器列表: username@ip (format)但是當我運行它時,它給了我替換錯誤

因此,我嘗試了pssh(parallel-ssh)

pssh -h hosts-file -l username -P $command

命令是./sr_run_batch.sh

但它沒有運行,所以我將其修改為

pssh -h hosts-file -l ben -P -I<./sr_run_batch.sh

但是,由於某些未知原因,它只是在代碼中打印echo語句。 這是代碼:

NList=(5)    
VList=(1)    
FList=("input/flower1.jpg" "input/flower2.jpg" "input/flower3.jpg" "input/flower4.jpg")    
IList=("320X240"            "640X480"           "1280X960"          "1920X1200")    
SList=(2 3)    
for VM in ${VList[@]}; do

    for ((index=0; index < ${#FList};)) do
        file=$FList[$index]
        image_size=$IList[$index]
        width=`echo $image_size|cut -d "X" -f1`
        height=`echo $image_size|cut -d "X" -f2`
        for scale_factor in ${SList[@]}; do
            for users in ${NList[@]}; do 
                echo "V: $VM, " "F: $file, " "S: $scale_factor, " "I: $width $height , " "N: $users"
                for i in `seq 1 $users` ; do
                    ./sr_run_once.sh $file $width $height $scale_factor &
                done
                wait
            done # for users            
        done # for scale_factor
    done # for index
done # for VM
exit 0

您是否也嘗試使用簡單的bash腳本pssh,那么看看通信設置是否正常?

$ pssh -h hosts.txt -A -l ben -P -I<./uptime.sh
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password: 
10.0.0.67:  11:06:50 up 28 min,  2 users,  load average: 0.00, 0.00, 0.00
[1] 11:06:50 [SUCCESS] 10.0.0.67
10.0.0.218:  11:06:50 up 24 min,  2 users,  load average: 0.00, 0.05, 0.20
[2] 11:06:50 [SUCCESS] 10.0.0.218

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM