Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
os.popen problem
#1
I'm trying to work on os.popen
When I try to do an ipconfig command, it gives me an error alert
Any other command for example ping 8.8.8.8 works great
Can someone help me understand why this is happening to me

Attached Files

Thumbnail(s)
   
Reply
#2
Use subprocess and advise run() function for all use cases it can handle.
import subprocess

result = subprocess.run(['ipconfig'], encoding='utf-8', capture_output=True)
print(result.stdout)
No force it to utf-8(Python's default encoding),Windows can sometime use charmap encoding when call external stuff.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020