Python Forum
how to run linux command with multi pipes by python !!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to run linux command with multi pipes by python !!
#1
hey all ..
i am trying to run this command on my machine by using python subprocess module ...
command :
ping -c 1 -t 1 -w 1 192.168.1.81 | grep "ttl=" | awk {'print $4'} | sed 's/.$//'
code

import subprocess

q= subprocess.run(['ping', '-c' ,'1' ,'192.168.1.81' , '| grep ttl' , ' awk {"print $4"}' , " sed 's/.$//'"], capture_output=True)
print(q.stdout.decode())
i dont get an error i just get an empty result !!
Reply


Messages In This Thread
how to run linux command with multi pipes by python !! - by evilcode1 - Jan-25-2021, 10:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is possible to run the python command to call python script on linux? cuten222 6 720 Jan-30-2024, 09:05 PM
Last Post: DeaD_EyE
  How to use a variable in linux command in python code? ilknurg 2 1,596 Mar-14-2022, 07:21 AM
Last Post: ndc85430
  use subprocess on linux\pi wwith a "grep " command korenron 2 8,065 Oct-19-2021, 10:52 AM
Last Post: DeaD_EyE
  Python syntax in Linux St0rmcr0w 2 50,443 Jul-29-2021, 01:40 PM
Last Post: snippsat
  Login to NordVPN on Linux with python script AGreenPig 2 5,958 Feb-09-2021, 10:44 AM
Last Post: AGreenPig
  Duplex pipes GrahamL 0 1,752 Dec-16-2020, 09:44 AM
Last Post: GrahamL
  Handling multi-input/output audio in python bor1904 4 3,570 Nov-04-2020, 08:25 AM
Last Post: CHLOVRL
  where to get portable Python for Linux (Fedora)? python001 5 6,291 Nov-01-2020, 05:23 PM
Last Post: Larz60+
  Embedding python cause crash when use boost::asio multi threading udvatt108 0 1,715 Oct-04-2020, 03:15 PM
Last Post: udvatt108
  Python in Linux environment on RPI kendias 22 11,061 Sep-05-2020, 03:04 AM
Last Post: K_Research

Forum Jump:

User Panel Messages

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