Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

MAC Address Changer Error

Hi there, small problem when I was working on my python script shown below:

Code
#!/usr/bin/env python

import subprocess

print("\n **MAC Address Changer 1.2** \n \n \n \n")
subprocess.call("ifconfig")
NETWORK = input("\n Please enter the Network Interface you wish to change (e.g wlan0, eth0) - ")
ADDRESS = input("\n Please enter the New MAC Address (E.G 11:22:33:44:55:66) - ")

subprocess.call("ifconfig {0} down").format(NETWORK)

subprocess.call("ifconfig {0} hw ether {1}".format(NETWORK, ADDRESS), shell=True)

The code throws up this error:

File "/root/Documents/PyCharmProjects/JB's Python Practice/MAC-Address-Changer.py", line 10, in <module>
   subprocess.call("ifconfig {0} down").format(NETWORK)
 File "/usr/lib/python3.7/subprocess.py", line 323, in call
   with Popen(*popenargs, kwargs) as p:
 File "/usr/lib/python3.7/subprocess.py", line 775, in_init_
   restore_signals, start_new_session)
 File "/usr/lib/python3.7/subprocess.py", line 1522, inexecute_child
   raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ifconfig {0} down': 'ifconfig {0} down'


Anyone got any hints about this? help is appreciated, thanks


Sorry, forgot about shell=True, but upon adding that I now recieve this error

SIOCSIFHWADDR: Cannot assign requested address


(Jun 5, 2019 08:10 AM)Magpi3 Wrote:  Hi there, small problem when I was working on my python script shown below:

Code
#!/usr/bin/env python

import subprocess

print("\n **MAC Address Changer 1.2** \n \n \n \n")
subprocess.call("ifconfig")
NETWORK = input("\n Please enter the Network Interface you wish to change (e.g wlan0, eth0) - ")
ADDRESS = input("\n Please enter the New MAC Address (E.G 11:22:33:44:55:66) - ")

subprocess.call("ifconfig {0} down").format(NETWORK)

subprocess.call("ifconfig {0} hw ether {1}".format(NETWORK, ADDRESS), shell=True)

The code throws up this error:

File "/root/Documents/PyCharmProjects/JB's Python Practice/MAC-Address-Changer.py", line 10, in <module>
   subprocess.call("ifconfig {0} down").format(NETWORK)
 File "/usr/lib/python3.7/subprocess.py", line 323, in call
   with Popen(*popenargs,
kwargs) as p:
 File "/usr/lib/python3.7/subprocess.py", line 775, in __init_

   restore_signals, start_new_session)
 File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
   raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ifconfig {0} down': 'ifconfig {0} down'


Anyone got any hints about this? help is appreciated, thanks


Sorry, forgot about shell=True, but upon adding that I now recieve this error

SIOCSIFHWADDR: Cannot assign requested address

Nevermind, problem solved, me being stupid


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by anoniminTRApr 29, 2018 05:01 AM 4 127 Apr 29, 2018 05:01 AM
Last Post: anoniminTR
[Java] by koolkidNov 11, 2013 10:01 PM 9 262 Nov 11, 2013 10:01 PM
Last Post: kray
[.NET] by shroomkidhackerJul 31, 2013 03:18 AM 2 121 Jul 31, 2013 03:18 AM
Last Post: getkilled22