Using sudo with Python script

sudoPassword = 'mypass'
command = 'mount -t vboxsf myfolder /home/myuser/myfolder'
p = os.system('echo %s|sudo -S %s' % (sudoPassword, command))

Try this and let me know if it works. 🙂

And this one:

os.popen("sudo -S %s"%(command), 'w').write('mypass')

Leave a Comment

tech