[Tutor] Shell scripting

Steve Willoughby steve at alchemy.com
Wed Sep 17 18:34:55 CEST 2008

On Wed, Sep 17, 2008 at 12:30:58PM -0400, Patrick wrote:
> I was just wondering if there was a way to return the results of a
> python script to the bash shell? I was thinking about using the output
> as an argumen for another shell command. I know that we can use the
> shell from within Python via the OS module but I believe this is usually
> used to feed input into the program.

Anything you print to the standard output stream (sys.stdout)
will be piped on to the next command.  This is true for any 
program executed from the shell.  So just a plain "print"
should do what you want.

> Here is a silly pseudo code example:
> bash command | some-python-script.py |  some.other-script.sh
> thanks in advance-Patrick
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

Steve Willoughby    |  Using billion-dollar satellites
steve at alchemy.com   |  to hunt for Tupperware.

More information about the Tutor mailing list