ssh remote host, execute command

#!/usr/bin/expect

spawn ssh user@host

set timeout 10
expect {
    timeout {
        puts "Connection timed out"
        exit 1
    }

    "yes/no" {
        send "yes\r"
        exp_continue
    }

    "password:" {
        send "password\r"
        exp_continue
    }

    "user*# " {
        send "command\r"
    }
}
expect eof
powered by GitbookFile Modify: 2022-06-08 14:37:30

results matching ""

    No results matching ""