Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import os
- # Define the command to run
- command = "ipconfig /all"
- # Run the command using subprocess
- result = subprocess.run(command, capture_output=True, text=True, shell=True)
- # Check if the command executed successfully === 0 - success
- if result.returncode == 0:
- print("Command executed successfully:")
- print(result.stdout)
- fname = "D:\\sand\\iplist.txt"
- file = open(fname, 'w')
- file.write(result.stdout)
- file.close()
- os.system(f'notepad {fname}')
- else:
- print("Command execution failed:")
- print(result.stderr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement