小编gan*_*kla的帖子

FileNotFoundError:[Errno 2]没有这样的文件或目录:'ifconfig'

我被教导如何通过两种方法更改 mac 地址,subprocess.call第一种方法成功,但第二种方法给我错误,我无法理解它,这是我的代码:

#! /usr/bin/python3.5
import subprocess
interface = input("Enter Interface of Your Choice: ")
mac_chg = input("Enter New Mac Address: ")
print("[+]Changing Mac ADDRESS of " + interface + " to " + mac_chg)
subprocess.call(["ifconfig", interface, "down"])
subprocess.call(["ifconfig", interface, "hw", "ether", mac_chg])
subprocess.call(["ifconfig", interface, "up"])
Run Code Online (Sandbox Code Playgroud)

这是错误:

Traceback (most recent call last):
  File "/home/kali/PycharmProjects/hello/main.py", line 7, in <module>
    subprocess.call(["ifconfig", interface, "down"])
  File "/usr/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__ …
Run Code Online (Sandbox Code Playgroud)

python linux subprocess

3
推荐指数
1
解决办法
2867
查看次数

标签 统计

linux ×1

python ×1

subprocess ×1