Shell自动交互的三种方法


方法一


(echo "password";) | read input_pwd

方法二


read input_pwd << EOF

password

EOF

方法三


#!/usr/bin/expect

spawn ssh root@192.168.0.1

expect "password:"

send "123\n"

interact

Advertisements