遠端分發sh指令碼

zhangsharp20發表於2015-12-31
#!/bin/bash
var1="scp -r /home/oracle/luhp/ " 
var2=:/home/oracle/ 
var3=`cat /monitor/dcli/gg_hostlist |grep -v "^$"|grep -v batch| sed -n "n;p"|grep "^#"|wc -l`


if [ ! -d "/home/oracle/luhp" ]; then
mkdir /home/oracle/luhp
fi
/bin/cp -r /samples/ogg/* /home/oracle/luhp
for ((i=1;i<=var3;i++))
do
  var=`cat /monitor/dcli/gg_hostlist |grep -v "^$"|grep -v batch| sed -n "n;p"|grep "^#"|sed -n ${i}p|cut -b 2-`
#  echo $i
#  echo ${var1}${var}${var2}
  test=`echo ${var1}${var}${var2}`
  $test    
done


rm -r /home/oracle/luhp

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29802484/viewspace-1969073/,如需轉載,請註明出處,否則將追究法律責任。

相關文章