0

このスクリプトを実行した後、vpn に自動的に接続するのに役立つシェル スクリプトを作成する必要があります。

vpnc プログラムには次の入力が必要です

root@xmpp3:/home/test/Desktop/ScriptTovpnc# vpnc
Enter IPSec gateway address: 
Enter IPSec ID for : 
Enter IPSec secret for @: 
Enter username for : 
Enter password for @: 
vpnc: unknown host `'

スクリプトを書くことができません。そのスクリプトでこれらすべてのパラメーターを渡す方法です。

4

1 に答える 1

2

anishsane のコメントは正しいです。設定ファイルを使用してください!

ただしexpect、念のため、データの入力を自動化するスクリプトを次に示します。

#!/usr/bin/expect

spawn vpnc

expect "Enter IPSec gateway address;"
send "yourdata\r";

expect "Enter IPSec ID for"
send "yourdata\r";

expect "Enter IPSec secret for"
send "yourdata\r";

expect "Enter username for"
send "yourdata\r";

expect "Enter password for"
send "yourdata\r";

Jonathan が提案するように、ほとんどのデータをコマンドライン引数として渡すと、サイズを小さくすることができます。

#!/usr/bin/expect

spawn vpnc --gateway yourgateway --id yourid --username yourusername

expect "Enter IPSec secret for"
send "yourdata\r";

expect "Enter password for"
send "yourdata\r";

しかし、すでに述べたように、それは進むべき道ではありません。代わりに設定ファイルを使用してください。

于 2013-09-06T09:55:24.590 に答える