有个需求,有个文件删除了,但是不确定线上机器还都存不存在 #!/home/work/.jumbo/bin/expect -f set timeout -1 set mac [lindex $argv 0] set password "***" spawn ssh [email protected]$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
时间: 2024-11-04 10:11:32