expect 示例

/usr/bin/expect<<EOF
        set timeout 50
        spawn $SCP_LOG_TO_GATHER_SERVER
        expect {
                "*yes/no)?" 
                 { 
                     send "yes\n"
                     "*password:*" {send "GatherServerPassword\n"}
                 } 
                "*password:"         
                 {
                     send "$GatherServerPassword\n"
                 }
               }
        expect "*password:"  { send "$GatherServerPassword\n" }
        expect "100%"
        expect eof

EOF

你可能感兴趣的:(expect)