[Tutor] Shell scripting

Chris Fuller cfuller084 at thinkingplanet.net
Wed Sep 17 21:08:25 CEST 2008


Here's a trivial example using backquotes.  The tricky part is getting bash to 
use them in conditionals, variable assignments, and such.

0 % cat > /tmp/fie.py
print "Fie!"
[ctrl-d]
0 % cat > /tmp/echo.sh
echo `python /tmp/fie.py`
[ctrl-d]
0 % sh /tmp/echo.sh
Fie!
0 %

Cheers


On Wednesday 17 September 2008 11:30, 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.
>
> 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


More information about the Tutor mailing list