Python Forum
problem in using subprocess module
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem in using subprocess module
#6
(Sep-24-2023, 11:09 AM)akbarza Wrote: hi snippet
I am not familiar with the subprocess library and your code:
response = subprocess.run(['ping', '-n' ,'4', 'python-forum.io'], capture_output=True, encoding='utf-8')
how(where) can I gain more info about the above code?
To explain the basic of this,so ping is a external program ping.exe that you have on your OS Windows .
From cmd:
C:\>ping -n 4 python-forum.io

Pinging python-forum.io [172.67.168.227] with 32 bytes of data:
Reply from 172.67.168.227: bytes=32 time=21ms TTL=53
Reply from 172.67.168.227: bytes=32 time=37ms TTL=53
Reply from 172.67.168.227: bytes=32 time=32ms TTL=53
Reply from 172.67.168.227: bytes=32 time=35ms TTL=53

Ping statistics for 172.67.168.227:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 21ms, Maximum = 37ms, Average = 31ms 
So it's a way to take a external programs into Python,and run it if program have output can also catch that.
Like this will just start FireFox from Python.
import subprocess

subprocess.run(['C:/Program Files (x86)/Mozilla Firefox/firefox.exe'])
Look at Doc for eg run().
Reply


Messages In This Thread
problem in using subprocess module - by akbarza - Sep-23-2023, 12:01 PM
RE: problem in using subprocess module - by akbarza - Sep-24-2023, 11:09 AM
RE: problem in using subprocess module - by akbarza - Sep-24-2023, 11:15 AM
RE: problem in using subprocess module - by snippsat - Sep-24-2023, 02:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with memory_graph module akbarza 3 447 Mar-04-2024, 10:15 AM
Last Post: snippsat
  problem using coloeama module akbarza 3 646 Jan-08-2024, 07:31 AM
Last Post: akbarza
  problem in import module from other folder akbarza 5 1,592 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  problem in using pyqrcode module to create QRcode akbarza 9 2,197 Aug-23-2023, 04:17 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 1,078 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  Problem with module time and leap seconds Pedroski55 3 1,297 Oct-07-2022, 11:27 PM
Last Post: Pedroski55
  Question on subprocess module. knoxvilles_joker 3 2,751 Apr-11-2021, 12:51 AM
Last Post: knoxvilles_joker
  keyboard module; must be root problem philipbergwerf 2 19,359 Apr-04-2021, 11:40 AM
Last Post: philipbergwerf
  Problem with Flask Bcrypt import module marcello86 2 5,850 Aug-31-2020, 08:10 PM
Last Post: marcello86
  Js2Py module not found problem Charliedactyl1 5 8,035 Jun-14-2020, 07:39 PM
Last Post: buran

Forum Jump:

User Panel Messages

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