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 + "\"')
use the subprocess module
import subprocess
subprocess.call(['sudo', vpnFile2, '--cd', vpnpath, '--config', cfgFile])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With