首页 > 代码库 > expect结合ssh遍历线上机器

expect结合ssh遍历线上机器

有个需求,有个文件删除了,但是不确定线上机器还都存不存在


#!/home/work/.jumbo/bin/expect -fset timeout -1set mac [lindex $argv 0]set password "***"spawn ssh username@$macexpect { "(yes/no)?" { send "yes\r" expect "*password:" { send "$password\r"} } "*password:" { send "$password\r"}}expect { "*password:" { send "\003" send_user "this mac nologin" } ".*" { send "cd /home/work/odp/data/app/searchbox/baiduboxapp/config/android/; ls\r" }}expect ".*"
#!/bin/bashget_instance_by_service *** | while read macdo        echo $mac        res=`./expect.sh $mac`        if echo $res | grep -q this mac nologin; then                echo -e "\e[1;31m======nologin\e[0m"        elif echo $res | grep -q opact; then                echo -e "\e[1;33m======has\e[0m"        else                echo -e "\e[1;32m======no\e[0m"        fidone

 

expect结合ssh遍历线上机器