12
Сен
2021

не могу понять в чем ошибка ,и где

File "poputka_04.09.2021.py", line 26, in change_mac(options.interface, options.new_mac) AttributeError: 'NoneType' object has no attribute 'interface'

сам код

    #!/usr/bin/env python
    
    import subprocess
    import optparse
    
    
    def get_arguments():
        parser = optparse.OptionParser()
        parser.add_option("-i", "--interface", dest="interface", help="Interface to change its MAC 
     address")
        parser.add_option("-m", "--mac", dest="new_mac", help="New MAC address")
        (options, arguments)= parser.parse_args()
        if  not options.interface:
            parser.error("[-] Please specify an interface,use --help for more info.")
        elif not options.new_mac:
            parser.error("[-] Please specify a new mac,use --help for more info.")
            return options
    
     def  change_mac(interface,new_mac):
        print("[+] Changing MAC address for " + interface + " to " + new_mac)
        subprocess.call(["ifconfig", interface, "down"])
        subprocess.call(["ifconfig", interface, "hw", "ether", new_mac])
        subprocess.call(["ifconfig", interface, "up"])
    
    
     options = get_arguments()
     change_mac(options.interface, options.new_mac)

Источник: https://ru.stackoverflow.com/questions/1327842/%D0%BD%D0%B5-%D0%BC%D0%BE%D0%B3%D1%83-%D0%BF%D0%BE%D0%BD%D1%8F%D1%82%D1%8C-%D0%B2-%D1%87%D0%B5%D0%BC-%D0%BE%D1%88%D0%B8%D0%B1%D0%BA%D0%B0-%D0%B8-%D0%B3%D0%B4%D0%B5

Тебе может это понравится...

Добавить комментарий