Expect

提供: Wikinote
2011年7月18日 (月) 22:28時点におけるHagio (トーク | 投稿記録)による版 (ページの作成:「man を読んでも書けるようになる気が全然してこない expect について。 == スクリプト集 == === 禁断の ssh 強引ログイン === この...」)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

man を読んでも書けるようになる気が全然してこない expect について。

スクリプト集

禁断の ssh 強引ログイン

このスクリプトは絶対に使用してはならない。

#!/usr/bin/expect -f
spawn ssh $argv
expect {
    "password:" {
        send "pass\n"
    }
    "continue connecting" {
        send "yes\n"
        exp_continue
    }
    "Host key verification failed" {
        system rm -f ~/.ssh/known_hosts
        spawn ssh $argv
        expect {
            "password:" {
                send "pass\n"
            }
            "continue connecting" {
                send "yes\n"
                exp_continue
            }
        }
    }
}
expect "Last login:"
send "ls\n"
interact
#send "exit\n"