微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我目前正在编写 MAC 转换器脚本,但遇到错误

如何解决我目前正在编写 MAC 转换器脚本,但遇到错误

这是我的代码

import subprocess
 
import optparse

parser = optparse.OptionParser()

parser.add_option("-i","--interface",dest="interface",help="interface to change MAC adress")

parser.add_option("-m","--mac",dest="mac",help="new mac adress")

(options,arguments) = parser.parse_args()

interface = options.interface

mac = options.mac 

#print("(+) Your mac adress for " + interface + " has been changed to " + mac)

subprocess.call(["sudo ifconfig",interface,"down"])

subprocess.call(["sudo ifconfig","hw","ether",mac])

subprocess.call(["sudo ifconfig","up"])

这是错误

Traceback (most recent call last):

  File "mac_changer.py",line 10,in <module>
    subprocess.call(["sudo ifconfig","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 858,in __init__
    self._execute_child(args,executable,preexec_fn,close_fds,File "/usr/lib/python3.8/subprocess.py",line 1639,in _execute_child

    self.pid = _posixsubprocess.fork_exec(
TypeError: expected str,bytes or os.pathLike object,not nonetype

我使用的是 Ubuntu 20.04。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。