「Expect」の版間の差分
提供: Wikinote
(ページの作成:「man を読んでも書けるようになる気が全然してこない expect について。 == スクリプト集 == === 禁断の ssh 強引ログイン === この...」) |
細 |
||
| 行5: | 行5: | ||
=== 禁断の ssh 強引ログイン === | === 禁断の ssh 強引ログイン === | ||
| − | + | あなたの名誉のために言っておくが、通常の環境ではこのスクリプトを'''絶対に使用してはならない。''' | |
| + | もし使用してしまった場合、あなたは鼻で笑われ、サポート部門からは無視されるだろう。 | ||
#!/usr/bin/expect -f | #!/usr/bin/expect -f | ||
| 行31: | 行32: | ||
} | } | ||
} | } | ||
| − | expect " | + | expect "#" |
| − | send " | + | send "w\n" |
| − | + | expect "#" | |
| − | + | send "exit\n" | |
| + | puts "exit" | ||
2012年2月13日 (月) 21:44時点における最新版
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 "#"
send "w\n"
expect "#"
send "exit\n"
puts "exit"