I\'m trying to use python Subprocess module to enable/disable Ethernet connection from python code. Below is my code in which the first step is looking for the available \"E
Use string formatting, interpolation, or concatenation:
x = 'Ethernet10'
subprocess.call('netsh interface set interface ' + x + ' ENABLED')
subprocess.call takes a list as an argument:
subprocess.call(['netsh', 'interface', 'set', 'interface', x, 'ENABLED'])
You could instead pass shell=True
and your string would work, but it is a security risk, since an user could for example call another command by using $(command_here)
If you still want to use a string, you could use shlex.split
.