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
  [SOLVED] [Linux] Run Python script through cron? Winfried 2 1,254 Oct-19-2024, 06:29 PM
Last Post: Winfried
  Linux, Python, C ++, Brain2 and errors. PiotrBujakowski 0 1,024 Jun-24-2024, 03:41 PM
Last Post: PiotrBujakowski
  Is possible to run the python command to call python script on linux? cuten222 6 2,411 Jan-30-2024, 09:05 PM
Last Post: DeaD_EyE
  How to use a variable in linux command in python code? ilknurg 2 2,441 Mar-14-2022, 07:21 AM
Last Post: ndc85430
  use subprocess on linux\pi wwith a "grep " command korenron 2 11,310 Oct-19-2021, 10:52 AM
Last Post: DeaD_EyE
  Python syntax in Linux St0rmcr0w 2 66,321 Jul-29-2021, 01:40 PM
Last Post: snippsat
  Login to NordVPN on Linux with python script AGreenPig 2 7,552 Feb-09-2021, 10:44 AM
Last Post: AGreenPig
  Duplex pipes GrahamL 0 2,367 Dec-16-2020, 09:44 AM
Last Post: GrahamL
  Handling multi-input/output audio in python bor1904 4 4,938 Nov-04-2020, 08:25 AM
Last Post: CHLOVRL
  where to get portable Python for Linux (Fedora)? python001 5 8,870 Nov-01-2020, 05:23 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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