sans_souciの日記

無憂茶房

sample source bash/chpasswd

chpasswd/bash

サンプル/仕掛中

素/ myfinish.txt

192.168.0.81,beforepwd01,afterpwd01
192.168.0.82,beforepwd02,afterpwd02

実行

cat myfinish.txt | awk -F',' \
'{printf \
  "echo \x22$(date +%%FT%%T) The password of %s is being changed...\x22 ; \
   sshpass -p \x27%s\x27 ssh -o StrictHostKeyChecking=no root@%s \
   \047echo \x22root:%s\x22 \\\x7c chpasswd\047 ; \
   echo \x22$(date +%%FT%%T) The password of %s is changed.\x22\n" \
  ,$1,$2,$1,$3,$1 \
 }' | tee result.txt

最後

cat result.txt | xargs -i bash -c "{}"

編集中/ 無理に似非一行にしないほうが良いかも・・