telnetを自動化するexpectスクリプトを作成しようとしています。これは私がこれまでに持っているものです。
#!/usr/bin/expect
# Test expect script to telnet.
spawn telnet 10.62.136.252
expect "foobox login:"
send "foo1\r"
expect "Password:"
send "foo2\r"
send "echo HELLO WORLD\r"
# end of expect script.
基本的に、私がやりたいのは、次のIPアドレスにtelnetで接続してから、HELLOWORLDをエコーすることです。ただし、telnetを試行した後、スクリプトが失敗したようです...ログインとパスワードの入力を受け入れることができるかどうかはわかりませんが、HELLOWORLDをエコーしていません。代わりに、次の出力を取得します。
cheungj@sfgpws30:~/justin> ./hpuxrama
spawn telnet 10.62.136.252
Trying 10.62.136.252...
Connected to 10.62.136.252.
Escape character is '^]'.
Welcome to openSUSE 11.1 - Kernel 2.6.27.7-9-pae (7).
foobox login: foo1
Password: foo2~/justin>