Python vs Unix shells

P

Paddy McCarthy

This is really a comment on "Python in Systems Administration: Part I
-- Better Scripting"
http://www.samag.com/documents/s=8964/sam0312a/0312a.htm
by Cameron Laird.

Reading the article, although I am a fan of Python, I kinda take issue
with the example given. It doesn't seem to fit with the concept of
'many smaller utilities doing one thing well, connected via pipes'

If I had the task of writing a Unix utility to match the GUI Python
example I would prefer to either:
1) save a sorted file listing to a temporary file then use either
$EDITOR or vi to edit the temporary file, and on completion extract
those files mentioned in the temporary file. OR
2) Write a general argument selector in Python that could be imported
in a larger Python prog as a module where its function would be to
display a python list of strings in a GUI and return those selected,
OR when executed as a command, it would display all its arguments in
the order given, and return those selected. The command line versions
could have options to sort the input and to either return space
separated or newline separated versions of its output (and maybe CSV
too).

The advantages of the first is that you would use the users $EDITOR.
The user will be on familiar territory, and not much extra programming
is needed.

The advantages of 2 are that you end up with a python module/script
that is *re-usable* both in a Python program and as a command line
script in the tradition of Unix utilities.
Such Python module/scripts if collected on a central web site could
form a useful resource for System Administrators.

Whoops, I almost forgot, The third way might be to look up utilities
for adding GUIs to command line utilities and using those. (e.g.
kaptain at http://kaptain.sourceforge.net )

To summarize then, using similar reasons for writing a script for the
simple tar extraction; when you write your Python version you might
want to modularize reusable components but also make that Python
module a command line utility itself.

Cheers, Pad.
 
W

William Park

In said:
This is really a comment on "Python in Systems Administration: Part I
-- Better Scripting"
http://www.samag.com/documents/s=8964/sam0312a/0312a.htm
by Cameron Laird.

Reading the article, although I am a fan of Python, I kinda take issue
with the example given. It doesn't seem to fit with the concept of
'many smaller utilities doing one thing well, connected via pipes'

What did you expect from a Python consultant? He has the right to make
a living and advertise his expertise.
 
P

Paddy McCarthy

William Park said:
What did you expect from a Python consultant? He has the right to make
a living and advertise his expertise.

Hi William,
I don't understand why you made your comment?
I was expecting replies of maybe "the pressures of getting an example
to fit the article made his example maybe a little artificial" (but
still useful). or people agreeing or disagreeing with the idea of
modules that are also Unix scripts.
I can't see how Cameron being a consultant has anything to do with it.

Cheers, Paddy.
 
C

Cameron Laird

.
.
.
.
.
.
I was expecting replies of maybe "the pressures of getting an example
to fit the article made his example maybe a little artificial" (but
still useful). or people agreeing or disagreeing with the idea of
modules that are also Unix scripts.
.
.
.
As I read your comments, you do a good job of answering all
the questions yourself. In other articles, I've said a few
words about the difficulty of writing good examples for an
audience of systems administrators; I do find it hard not
being "maybe a little artificial" (I appreciate your gentle
touch), without complexification that loses the reader.

Your posts challenge me, but in a good way. I do want to
say that one of my favorite signs of health in Pythoneering
is the tradition of using the "if __name__ == '__main__':..."
idiom to compose source which is both importable and
executable.

So: can I enlist you to review my drafts?
 
D

Donn Cave

... In other articles, I've said a few
words about the difficulty of writing good examples for an
audience of systems administrators; I do find it hard not
being "maybe a little artificial" (I appreciate your gentle
touch), without complexification that loses the reader.

Maybe the category is a little artificial, in that system
administration isn't really a computer programming domain
like numeric, hardware control, rendering, web publishing.

I suppose that's part of your point, when you talk about
writing your own tools rather than buying packaged solutions.
Not many good packaged solutions for Miscellaneous Little Tasks.

Donn Cave, (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,477
Latest member
ColumbusMa

Latest Threads

Top