#!/usr/bin/python3
import subprocess
import optparse
def get_arguments():
parser = optparse.OptionParser()
parser.add_option("-i", "--interface", dest="interface", help="goo")
parser.add_option("-m", "--mac", dest="new_mac", help="yeees")
return parser.parse_args()
def change_mac (interface, new_mac):
print ("changing MAC ADDRESS FOR :{} to {}" (interface, new_mac)
subprocess.call(["ifconfig", interface, "down"]) ## the problem
subprocess.call(["ifconfig", interface, "hw ", " ether ", new_mac])
subprocess.call(["ifconfig", interface, "up"])
get_arguments()
change_mac (options.interface, options.new_mac)
CodePudding user response:
The syntax error is declared at line 17 but actually occurs at the end of line 16. You just need to close the parenthesis of the call of the function print
. Also, the way you try to add the variables interface
and new_mac
in the string is incorrect; you need to use the format
function.
Here is the code fixed:
[...]
def change_mac (interface, new_mac):
print ("changing MAC ADDRESS FOR :{} to {}".format(interface, new_mac)) # FIXED
subprocess.call(["ifconfig", interface, "down"])
[...]