tags:

views:

48

answers:

1

How do I get python to run sudo openvpn --cd /etc/openvpn --config client.ovpn

I'm trying the following at the minute without success

vpnfile2 = '/etc/init.d/openvpn'
cfgFile = 'client.ovpn'

os.system('sudo \"" + vpnFile2 + "\" --cd \"" + vpnpath + "\" --config \"" + cfgFile + "\"')
+7  A: 

use the subprocess module

import subprocess
subprocess.call(['sudo', vpnFile2, '--cd', vpnpath, '--config', cfgFile])
gnibbler