Guide to using python for bash-style scripting
bill.pursell at gmail.com
Tue May 23 20:29:19 CEST 2006
> Yes, there is a stupid mistake in that script, last line should be:
> diff new_out1 new_out2
> However, this is hopefully not important, what is important is the
> general kind of (very simple) things I'm trying to do.
I have been hoping for a good solution to this. An
easy way to handle simple commands is:
s = "echo foo | sed 's/foo/gap/' > file\n"
s += "wc -c file\n"
s += "cat file\n"
print s, "***"
(Apologies for the lameness of the commands above).
However, I have some bash scripts that rely on
things like PIPESTATUS, and I have no idea
how to emulate that behavior easily. How can one
most easily emulate a simple pipe as readily
as in bash? I've seen a few recipes for doing something
like that, but I haven't yet seen one that i really
like. Is it possible to execute:
os.system( " a | b | c | d | e")
and retrieve the value of PIPESTATUS?
More information about the Python-list