Feb-16-2019, 02:24 AM
last year i posted a 22 line version of a function to run a pipeline of multiple commands.
today i am posting a much shorter version with only 10 lines.
pipecmds.py
if you saved the old 22 line version, please replace it or augment it with this new 10 line version.
today i am posting a much shorter version with only 10 lines.
pipecmds.py
import subprocess def pipecmds(*cmds,**opts): if not cmds: return p = [] for cmd in cmds[:-1]: p.append(subprocess.Popen(cmd,stdout=subprocess.PIPE,**opts)) opts['stdin']=p[-1].stdout p.append(subprocess.Popen(cmds[-1],**opts)) return [x.wait() for x in p]this function takes a list of the command argument strings in each function call argument for as many commands you want to run in a pipeline up to the maximum resources your hardware, system, or system administrator allows. you may use a tuple in place of any list.
if you saved the old 22 line version, please replace it or augment it with this new 10 line version.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.