有个需求,有个文件删除了,但是不确定线上机器还都存不存在 #!/home/work/.jumbo/bin/expect -f
set timeout -
set mac [lindex $argv ]
set password "***"
spawn ssh username@$mac
expect {
"(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/bash
get_instance_by_service *** | while read mac
do
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"
fi
done