Saturday, August 27, 2011

[Level 2] Use expect to run openvpn.

#!/usr/bin/expect
set password [lindex $argv 0]
spawn sudo openvpn --script-security 2 --config /home/stanley/VPN/MyVPN_config/MyVPN.ovpn
expect Enter\ Private\ Key\ Password:
sleep 1
send $password
sleep 1
interact
Test run:
# ./openvpn.expect mypassword
Wish this helps.
 regards,
Stanley Huang