leak
leak

Reputation: 95

Python run an executable file in python using subprocess windows 10

I'm trying to run massdns.exe which is in the same folder as my python file

subprocess.run("dir", shell=True)

output

Volume in drive C has no label.
 Volume Serial Number is A6AB-C832

 Directory of C:\Users\Owner\Desktop\folder1\folder2\massdns

02/02/2020  07:59 PM           251,991 massdns.exe

as you can see, it's in the same folder.

when I try doing subprocess.run(".\massdns.exe -r lists/resolvers.txt -t AAAA -w results.txt generated_domains.txt", shell=True) it does nothing. While, in the command line window or while in the powershell window, it runs the program as expected.

Things I have tried subprocess.check_output("massdns.exe -r lists/resolvers.txt -t AAAA -w results.txt generated_domains.txt", shell=True)

subprocess.run(".\massdns.exe -r lists/resolvers.txt -t AAAA -w results.txt generated_domains.txt", shell=True)

When I do this

subprocess.check_output("massdns.exe -r lists/resolvers.txt -t AAAA -w results.txt generated_domains.txt", shell=True)

I get this error

subprocess.CalledProcessError: Command 'massdns.exe -r lists/resolvers.txt -t AAAA -w results.txt generated_domains.txt' returned non-zero exit status 3221225781.

Upvotes: 0

Views: 619

Answers (1)

leak
leak

Reputation: 95

I figured out my problem, which would have been really hard to answer if you weren't in the same room as me. I'm using pycharm and I moved the massdns.exe file into another folder (the same folder I was trying to execute it in python though) and I didn't close my pycharm's command line, which I guess somehow messes with it, I closed pycharm alltogether and ta-da it worked.

Upvotes: 1

Related Questions