expect -c "
set timeout -1;
spawn ssh root@192.168.6.132;
expect {
*(yes/no)* {send yes\r ;exp_continue;}
*password* {send 123456\r ;exp_continue;}
eof {exit 0 }
}";
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31506529/viewspace-2199362/ ,如需转载,请注明出处,否则将追究法律责任。