[Tutor] python & bash combination

Remco Gerlich scarblac@pino.selwerd.nl
Sat, 9 Mar 2002 19:24:35 +0100


On  0, Andrei Raevsky <raevsky@hotmail.com> wrote:
> Hi!
> 
> I am total newbie at Python (I have been looking at it for a week or so) and 
> I am curious as to whether and how I could combine Python and Bash commands 
> in one single script.
> 
> If I begin my script with
> 
> #!/usr/bin/env python
> 
> I probably cannot suddently write:
> 
> #!/usr/bin/bash
> 
> now can I?
> 
> How could I write something combining 2-3 lines of Python, then say one Bash 
> command (to for example load a string variable) and then continue with 2-3 
> lines of Python?
> 
> Is this type of "expanding possible"?

You can call bash commands from Python with os.system(), and start commands
to get their output with os.popen(), for instance.

Most of the things that bash does can be done more easily in Python though,
I think. What do you mean with 'load a string variable'?

-- 
Remco Gerlich