CentOSでのexpectの使用方法について教えていただけないでしょうか。
シェルでのexpectにより、対話型の入力を自動で行うため、下記のようなコマンドを実装しようと考えております。
test.sh
1expect -c " 2 spawn reboot 3 expect \"Password:\" 4 send \"vagrant\" 5"
ところがいざ実行してみると、
[vagrant@localhost tmp]$ sh test.sh spawn reboot ==== AUTHENTICATING FOR org.freedesktop.login1.reboot === Authentication is required for rebooting the system. Authenticating as: root Password: [vagrant@localhost tmp]$
などと表示され、expectによるパスワードの入力が実行されておりません。
どなたかわかる方、アドバイスいただけないでしょうか。
追記:
ちなみにmysqlの初期化コマンドで試してみました。
どうやらsendコマンドが機能していないようです。
使い方が間違っているのでしょうか?
ss.sh
1expect -c " 2 spawn mysql_secure_installation 3 expect \"Enter password for user root:\" 4 send \"Fjjrk195_\n\" 5"
[vagrant@localhost tmp]$ sh ss.sh spawn mysql_secure_installation Securing the MySQL server deployment. Enter password for user root: [vagrant@localhost tmp]$
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/03/05 01:24
2017/03/05 01:28
2017/03/05 01:33
2017/03/05 01:35
2017/03/05 01:36