Python Forum
Filtering an interactive CLI command via pipe(s)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filtering an interactive CLI command via pipe(s)
#1
i have one or more CLI commands to run.  they could be run in a Python script by using subprocess.call though this is not the ultimate method.  what i would like to do is make a Python script frontend that filters the input and filters the output.  by filter i mean some kind of processing i decide on such as appending changing filename extensions on inputs and adding timestamps on outputs.  so there certainly needs to be a pipe or pipes between the filter script and the stdin and stdout of the interactive program to be run.

i am looking for examples of this kind of code or descriptions of exactly what to do (code).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
Something like:
ls | myscript.py | cat
That could be as easy as just reading stdin and print()ing out, and letting the os handle piping?
Reply
#3
(Nov-15-2016, 08:45 PM)nilamo Wrote: Something like:
ls | myscript.py | cat
That could be as easy as just reading stdin and print()ing out, and letting the os handle piping?

i have done things like that in shell script.  i want to do it all in python.  there may be cases where i will feed output back to input.  gotta be careful to avoid totally (b)locking.  that's why i want to use python.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Interactive plots that can be embed in web page mouse9095 1 609 Jun-12-2023, 04:51 PM
Last Post: deanhystad
  Convert Excel file into csv with Pipe symbol.. mg24 4 1,340 Oct-18-2022, 02:59 PM
Last Post: Larz60+
  BrokenPipeError: [Errno 32] Broken pipe throwaway34 6 9,361 May-06-2021, 05:39 AM
Last Post: throwaway34
  interactive map and function hurc60248 1 1,771 Jan-08-2021, 09:22 PM
Last Post: Larz60+
  Duplex Named Pipe with Python Server and C# Clients raybowman 1 2,411 Dec-03-2020, 09:58 PM
Last Post: Gribouillis
  2 or more processes on the write end of the same pipe Skaperen 4 3,886 Sep-27-2020, 06:41 PM
Last Post: Skaperen
  STT: recognition connection failed: [Errno 32] Broken pipe GrahamBerends 0 5,084 Jul-18-2020, 11:00 PM
Last Post: GrahamBerends
  Interactive Menu, String Search? maggotspawn 3 2,593 May-11-2020, 05:25 PM
Last Post: menator01
  multiprocessing Pipe.poll very slow seandepagnier 0 2,361 Mar-09-2020, 03:10 AM
Last Post: seandepagnier
  for / else not working in interactive mode Skaperen 4 2,571 Jul-17-2019, 06:16 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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