中断されると予想されるスクリプト

中断されると予想されるスクリプト

Expectを使用してovpnでログインプロセスを自動化しようとしていますが、一部のエラーが正しく進行しません。私のスクリプト:

#!/usr/bin/expect -f
set timeout -1

spawn openvpn --config ./bin/openvpn-lib/cert.ovpn --dev ovpntun0 --up ./bin/openvpn-  lib/update-resolv.conf --down ./bin/openvpn-lib/update-resolv.conf --script-security 2

expect "Enter Auth Username:"

send "myuser\n"

expect "Enter Auth Password:"

send "mypass\n"

interact

実行しようとすると、scriptitは次のエラーを報告します。

vpn_expect.sh: line 4: spawn: command not found
couldn't read file "Enter Auth Username:": no such file or directory
vpn_expect.sh: line 8: send: command not found
couldn't read file "Enter Auth Password:": no such file or directory
vpn_expect.sh: line 12: send: command not found
vpn_expect.sh: line 14: interact: command not found
vfbsilva@rohan ~ $ 

ベストアンサー1

ExpectスクリプトはExpectとして実行する必要があります。

expect <script_name>

シェルスクリプトとして実行

sh <script_name>

問題の原因です。

おすすめ記事