When you write, "Can I export a variable ...", are you asking that the
result of an external process be bound to a Python name (or variable), OR
that a Python process export a "shell" variable to its environment, OR
....?
--

Daven Nair fed this fish to the penguins on Thursday 11 December 2003
10:30 am:
> I would like to know if Python supports codes similar to shell
> scripts:
>
> count=`ps -ef|grep "pattern"|wc -l`
> for count in `echo $count`

I suspect you would have to separate the `...` items, using something
like one of the popen() family, and capture the results, then process
those same results.

(o)REXX would be a bit more transparent (though I don't think IBM
makes it free to all -- you can get an "evaluation" copy for Linux). In
REXX, anything line that is not recognized as a REXX statement is
automatically passed to the current command processor (normally the
shell -- though the Amiga really took advantage of the ability to
change "command processor" making AREXX a scripting language for any
application that created an "AREXX port").

Shell is generally better at quickly gluing together existing
commands. But does so at a significant cost in machine resources
and often execution time. Python provides a different approach
that is generally better where the solution must be repeated
often or where no suitable set of commands already exists.

In article <>,
Dennis Lee Bieber <> wrote:
.
.
.
> (o)REXX would be a bit more transparent (though I don't think IBM
>makes it free to all -- you can get an "evaluation" copy for Linux). In
.
.
.
There *are* open-source REXXs (even a mod_rexx!) which are
alternatives to IBM's. Normally, at this point, I'd provide
references to a couple; a combination of catastrophes seems
to be afflicting my REXX-related notes, though, and I have
none at hand that satisfy me. I'll cross-post to c.l.r for
the benefit of those who want to pursue this.
--

Alan Gauld <> wrote:
> On 12 Dec 2003 01:58:23 GMT, William Park <>
> wrote:
> > In any case, although Python does something well, shell does most
> > things better. (It's okey... I've got my helmet on.)
>
> Shell is generally better at quickly gluing together existing
> commands. But does so at a significant cost in machine resources and
> often execution time. Python provides a different approach that is
> generally better where the solution must be repeated often or where no
> suitable set of commands already exists.

"William Park" <> wrote in message news:brd7nv$264kc$-berlin.de...
> Alan Gauld <> wrote:
> > On 12 Dec 2003 01:58:23 GMT, William Park <>
> > wrote:
> > > In any case, although Python does something well, shell does most
> > > things better. (It's okey... I've got my helmet on.)
> >
> > Shell is generally better at quickly gluing together existing
> > commands. But does so at a significant cost in machine resources and
> > often execution time. Python provides a different approach that is
> > generally better where the solution must be repeated often or where no
> > suitable set of commands already exists.
>
> That is true, until you learn and program in shell.

And that will be true again once you have handy module for gluing
together cli applications. Since Python is not popular among
system administrators, nobody was bothered to do it (yet?)

On 12 Dec 2003 20:17:04 GMT, William Park <>
wrote:
> > often execution time. Python provides a different approach that is
> > generally better where the solution must be repeated often or where no
> > suitable set of commands already exists.
>
> That is true, until you learn and program in shell.

Well I've been programming Bourne and Korn shells for about 15
years now. But I still pick python for anything that needs a GUI
or has to run as a daemon or does heavy network calls. I'd also
use Python if I had to write a Web Browser or Word Processor or
Programming/Test environment.

In fact anything that needs more than a few hundred lines of
code. Shell is great for what its good at but orders of magnitude
slower and more resource hungry than Python for complex tasks.
Just think about how many processes get launched, the inefficient
text parsing, the nested shells etc. And as for data structure
support!

For sys admin type tasks, Shell is great, for applications its a
forced fit.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!