Ubuntu の expect コマンド

Ubuntu の expect コマンド

SuperUser をくまなく検索しましたが、解決策が見つかりません。 以下は、 を使用して ssh に使用しているスクリプトですexpect。 私は ubuntu を使用しており、 を使用して expect をインストールしましたaptitude install expect

#!/usr/bin/expect -f

spawn ssh user@server
expect "Password:"
send "mypassword\r"
interact

このスクリプトファイルsh script.shを実行すると、次のエラーが発生します。

test.sh: 3: spawn: not found
couldn't read file "Password:": no such file or directory
test.sh: 5: send: not found
test.sh: 6: interact: not found

この投稿を試してみましたが、うまくいきませんでした。 パスワードを入力せずに ssh を使用する Ubuntu 10.04

ありがとう、

答え1

ファイルを実行可能にする必要があります:

chmod +x script.sh

次のように実行します:

./script.sh

関連情報