By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,584 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,584 IT Pros & Developers. It's quick & easy.

Is Python as capable as Perl for sysadmin work?

P: n/a
I recently posted this sort of question to the c.l.p.m but
didn't get much of a response. I know a little Perl and a
little Python, but master neither at the moment.

I see that Python is a general purpose OO programming language
that finds use among some system administrators, but my guess
is that Perl is still more common in that area than Python.

For sysadmin-related tasks, is Python as useful as Perl, or
does it get clumsy when often dealing with the stuff admins
deal with on a regular basis?

At some point during some dingy job in the back boiler room
of Unix, would you find yourself saying, "geez, I'd wish I
started this with Perl -- Python just isn't cutting it." ?

Thanks,
---J

--
--- if replying via email, remove zees ---
Jul 18 '05 #1
Share this Question
Share on Google+
23 Replies


P: n/a

John M. Gabriele wrote:
I recently posted this sort of question to the c.l.p.m but
didn't get much of a response. I know a little Perl and a
little Python, but master neither at the moment.

I see that Python is a general purpose OO programming language
that finds use among some system administrators, but my guess
is that Perl is still more common in that area than Python.

For sysadmin-related tasks, is Python as useful as Perl, or
does it get clumsy when often dealing with the stuff admins
deal with on a regular basis?


I'm a Windows user, not a Unix sysadmin, but I've noticed that
Cameron Laird has written several articles on Python for system
administration in Unix Review and Sys Admin magazine, for example
http://www.unixreview.com/documents/s=9083/sam0401d/ . Reading his
articles may help you decide if Python is a good fit for your work.

Jul 18 '05 #2

P: n/a
On Mon, 07 Feb 2005 20:13:30 -0800, beliavsky wrote:

[snip]

I'm a Windows user, not a Unix sysadmin, but I've noticed that
Cameron Laird has written several articles on Python for system
administration in Unix Review and Sys Admin magazine, for example
http://www.unixreview.com/documents/s=9083/sam0401d/ . Reading his
articles may help you decide if Python is a good fit for your work.


Great series of articles. Thanks for the link. :)

--
--- if replying via email, remove zees ---
Jul 18 '05 #3

P: n/a
In article <pa****************************@yahooz.com>,
John M. Gabriele <jo************@yahooz.com> wrote:

For sysadmin-related tasks, is Python as useful as Perl, or does it get
clumsy when often dealing with the stuff admins deal with on a regular
basis?

At some point during some dingy job in the back boiler room of Unix,
would you find yourself saying, "geez, I'd wish I started this with
Perl -- Python just isn't cutting it." ?


Not likely. I'm a programmer, not a sysadmin, but my company's too
small for a sysadmin, so I and the other two programmers get elected.
(For example, today most of my time was spent hunting down kernel
patches for Red Hat 7.3 -- long story.)

Anyway. Have you ever noticed how shell scripts keep getting longer?
Ever notice how it gets harder to figure out what the heck any given
script's doing? Well, that's where Python helps you out compared to
Perl. Python can be a bit clumsier than Perl for dirt-simple tasks, but
you'll find that Python scales much better than Perl.
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code --
not in reams of trivial code that bores the reader to death." --GvR
Jul 18 '05 #4

P: n/a
In article <pa****************************@yahooz.com>,
"John M. Gabriele" <jo************@yahooz.com> wrote:
I recently posted this sort of question to the c.l.p.m but
didn't get much of a response. I know a little Perl and a
little Python, but master neither at the moment.

I see that Python is a general purpose OO programming language
that finds use among some system administrators, but my guess
is that Perl is still more common in that area than Python.

For sysadmin-related tasks, is Python as useful as Perl, or
does it get clumsy when often dealing with the stuff admins
deal with on a regular basis?

At some point during some dingy job in the back boiler room
of Unix, would you find yourself saying, "geez, I'd wish I
started this with Perl -- Python just isn't cutting it." ?

Thanks,
---J


Given that Perl was *designed* for sysadmin work, it's not surprising that
there are some features of it which make it very convenient to use in that
arena. For executing external commands, nothing really comes close to
Perl's back-tick syntax. For doing things like reading a sequence a files
and filtering the combined contents with regular expressions, Perl is
probably the tool that lets you do that in the most compact way.

As a general-purpose programming language, it sucks. My personal opinion
is that the general-purpose suckitude outweighs the domain-specific
sysadmin convenience.
Jul 18 '05 #5

P: n/a
"John M. Gabriele" <jo************@yahooz.com> writes:
At some point during some dingy job in the back boiler room
of Unix, would you find yourself saying, "geez, I'd wish I
started this with Perl -- Python just isn't cutting it." ?


Sometimes I have to write a quick script in Perl because Python isn't
ubiquitous enough around here, and I often find myself thinking I
the opposite... "Perl just isn't cutting it."

And I spent several years putting food on the table with Perl, so it's
not like I'm a noob with Perl.

Nick

--
# sigmask || 0.2 || 20030107 || public domain || feed this to a python
print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?')
Jul 18 '05 #6

P: n/a
Aahz wrote:
[snip]

Anyway. Have you ever noticed how shell scripts keep getting longer?
Yup.
Ever notice how it gets harder to figure out what the heck any given
script's doing?
Yup.
Well, that's where Python helps you out compared to
Perl. Python can be a bit clumsier than Perl for dirt-simple tasks, but
you'll find that Python scales much better than Perl.


Check. Thanks Aahz. :)

--
-- remove zees if contacting via email --
Jul 18 '05 #7

P: n/a
Nick Vargish wrote:
"John M. Gabriele" <jo************@yahooz.com> writes:

At some point during some dingy job in the back boiler room
of Unix, would you find yourself saying, "geez, I'd wish I
started this with Perl -- Python just isn't cutting it." ?

Sometimes I have to write a quick script in Perl because Python isn't
ubiquitous enough around here, and I often find myself thinking I
the opposite... "Perl just isn't cutting it."

And I spent several years putting food on the table with Perl, so it's
not like I'm a noob with Perl.

Nick


Thanks Nick (and everyone else) for the replies. Much appreciated.
--
--- remove zees if replying via email ---
Jul 18 '05 #8

P: n/a
No.

Unlike Perl, Python implements only a *finite turning machine* model of
computation. An easy way to see this limitation is in the following
code:
1.0 / 10.0

0.10000000000000001
In an infinite Turning machine, there would be an unbounded number of
zeros before the second 1, giving the exact result, not a numeric
approximation.

There's another little-known fact about Python: No string is permitted
to end with a backslash! You might think that variations like
r'\'
or
""""""\\\\\""""""
would allow you to create this elusive value, but you'd mistaken!
Now, this may not bother Unix sysadmins, but the honest truth is that
you'll be administrating Windows systems, too, anywhere you work!

Finally, Python just doesn't respond to threats as well as Perl does.
I have run into many Perl programs that just didn't quite work right
until I wrote '... or die "$!"' in the right places. Well, if you ever
have to threaten Python, just keep in mind that '... or die' just plain
won't work. You have to suggest that it 'try ... except', which is
really offensive. If I want to beg my computer to run programs, I know
where to find Intercal with its "PLEASE" and "DO PLEASE" constructions.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFCCP7WJd01MZaTXX0RAmCAAKCeRhKyxIfY0CE7IXce+v 9z5z3wTQCghTqH
VKdS8hwqlr7zWdm8piCRdbY=
=bbHJ
-----END PGP SIGNATURE-----

Jul 18 '05 #9

P: n/a
Jeff Epler wrote:

There's another little-known fact about Python: No string is permitted
to end with a backslash! You might think that variations like
r'\'
or
""""""\\\\\""""""
would allow you to create this elusive value, but you'd mistaken!
Now, this may not bother Unix sysadmins, but the honest truth is that
you'll be administrating Windows systems, too, anywhere you work!

a = "\\"
print a

\

Marc
Jul 18 '05 #10

P: n/a
On Tue, 08 Feb 2005 18:18:13 +0000, Marc Huffnagle wrote:
Jeff Epler wrote:

There's another little-known fact about Python: No string is permitted
to end with a backslash! You might think that variations like
r'\'
or
""""""\\\\\""""""
would allow you to create this elusive value, but you'd mistaken!
Now, this may not bother Unix sysadmins, but the honest truth is that
you'll be administrating Windows systems, too, anywhere you work!

>>> a = "\\"
>>> print a

\


That's really the only problem you had with his post?

:-O

*wink*
Jul 18 '05 #11

P: n/a
Jeff Epler wrote:
No.

Unlike Perl, Python implements only a *finite turning machine* model of
computation. An easy way to see this limitation is in the following
code:
>>> 1.0 / 10.0
0.10000000000000001

<<Snip>>

Jeff


Nice,
Made my evening :-)

- Pad.
Jul 18 '05 #12

P: n/a
Jeff Epler schrieb:
There's another little-known fact about Python: No string is permitted
to end with a backslash!
Sure you meant string literals. But that is wrong, too:
a = '\\'
print a

\

A Python string mustn't end with an *odd* number of backslashes. Other-
wise a literal using backslash escapes like 'don\'t do that' couldn't
be parsed.
Now, this may not bother Unix sysadmins, but the honest truth is that
you'll be administrating Windows systems, too, anywhere you work!
This is no problem, thanks to os.path.join() ;)
Well, if you ever
have to threaten Python, just keep in mind that '... or die' just plain
won't work. You have to suggest that it 'try ... except', which is
really offensive. If I want to beg my computer to run programs, I know
where to find Intercal with its "PLEASE" and "DO PLEASE" constructions.


Sysadmin work with Intercal? Go ahead! ;) But what's wrong with a
protecting try .. except block vs. "... or die" for every command
to be protected?

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
-------------------------------------------------------------------
Jul 18 '05 #13

P: n/a
Jeff Epler schrieb:
Unlike Perl, Python implements only a *finite turning machine* model of
computation. An easy way to see this limitation is in the following
code:
>>> 1.0 / 10.0

0.10000000000000001
In an infinite Turning machine, there would be an unbounded number of
zeros before the second 1, giving the exact result, not a numeric
approximation.


Boy, you are cheating us!!!! Wake up, this isn't April 1st! :)))

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
-------------------------------------------------------------------
Jul 18 '05 #14

P: n/a
Jeff Epler wrote:
No.

Unlike Perl, Python implements only a *finite turning machine* model of
computation. An easy way to see this limitation is in the following
code:
>>> 1.0 / 10.0
0.10000000000000001
In an infinite Turning machine, there would be an unbounded number of
zeros before the second 1, giving the exact result, not a numeric
approximation.


Another thing is that in Perl it turns left, while in Python it turns
right. hence the .rfind() string method.

Well, if you ever
have to threaten Python, just keep in mind that '... or die' just plain
won't work. You have to suggest that it 'try ... except', which is
really offensive. If I want to beg my computer to run programs, I know
where to find Intercal with its "PLEASE" and "DO PLEASE" constructions.


Wasn't there talk about a "try harder" recently?

try:
statement
tryharder:
statement
--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
Jul 18 '05 #15

P: n/a
Jeff Epler <je****@unpythonic.net> wrote:
Finally, Python just doesn't respond to threats as well as Perl does.
I have run into many Perl programs that just didn't quite work right
until I wrote '... or die "$!"' in the right places.


I find

'... or die "You $@$!"'

works even better ;-)

Thanks for a very amusing post!
--
Nick Craig-Wood <ni**@craig-wood.com> -- http://www.craig-wood.com/nick
Jul 18 '05 #16

P: n/a
In article <42*********************@dread12.news.tele.dk>,
Max M <ma**@mxm.dk> wrote:
Jeff Epler wrote:
No.

Unlike Perl, Python implements only a *finite turning machine* model of
computation. An easy way to see this limitation is in the following
code:
>>> 1.0 / 10.0

0.10000000000000001
In an infinite Turning machine, there would be an unbounded number of
zeros before the second 1, giving the exact result, not a numeric
approximation.


Another thing is that in Perl it turns left, while in Python it turns
right. hence the .rfind() string method.

Well, if you ever
have to threaten Python, just keep in mind that '... or die' just plain
won't work. You have to suggest that it 'try ... except', which is
really offensive. If I want to beg my computer to run programs, I know
where to find Intercal with its "PLEASE" and "DO PLEASE" constructions.


Wasn't there talk about a "try harder" recently?

try:
statement
tryharder:
statement


How about the Yoda version:

do:
statement
do not do:
statement
Jul 18 '05 #17

P: n/a
Roy
How about the Yoda version:

do:
statement
do not do:
statement


The Yoda version actually goes

statement
:do
statement
:not do

Caleb
Jul 18 '05 #18

P: n/a
Jeff Epler wrote:
If I want to beg my computer to run programs, I know
where to find Intercal with its "PLEASE" and "DO PLEASE" constructions.

Was it INTERCAL that had the COMEFROM <Line number> statement instead of
GOTO? I REALLY like the idea of a COMEFROM statement. I think python should
have a COMEFROM statement, but since perl revels in being impenetrable, I
suppose perl is likely to get it first. Shame.

Steve
Jul 18 '05 #19

P: n/a
Jeff Epler wrote:

Unlike Perl, Python implements only a *finite turning machine*


That's interesting -- I didn't know Python could be
used as a lathe. You learn something new every day!

I suppose an "infinite turning machine" would
be a really *big* lathe...

--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
Jul 18 '05 #20

P: n/a
Well, that's where Python helps you out compared to
Perl. Python can be a bit clumsier than Perl for dirt-simple tasks, but
you'll find that Python scales much better than Perl.


My opinion:

If "scales" refers to the /manageability/ of the code produced,
I'd say that Python scales better than C++. I would /much/ rather
manage a million lines of Python than a million lines of C++.

*checks self to see if self is wearing rose colored glasses*

*doesn't think so*

C//

Jul 18 '05 #21

P: n/a
Courageous wrote:

*checks self to see if self is wearing rose colored glasses*


assert(self.glasses.color != 'rose')

;)

Jeff Shannon
Technician/Programmer
Credit International

Jul 18 '05 #22

P: n/a

[Steve]
Was it INTERCAL that had the COMEFROM <Line number> statement instead of
GOTO? I REALLY like the idea of a COMEFROM statement. I think python should
have a COMEFROM statement


It does - see http://entrian.com/goto/

(In case you doubt it: yes, it works, but note that it doesn't work at the
interactive prompt, only in a real source file.)

(The fact that I felt obliged to add the first paragraph on that page is
the funniest part of the whole thing. I really did have people genuinely
thanking me for the module, asking for features, asking for help with
using it, and so on.)

--
Richie Hindle
ri****@entrian.com

Jul 18 '05 #23

P: n/a
Richie Hindle wrote:
[Steve]
Was it INTERCAL that had the COMEFROM <Line number> statement instead of
GOTO? I REALLY like the idea of a COMEFROM statement. I think python should
have a COMEFROM statement

It does - see http://entrian.com/goto/

(In case you doubt it: yes, it works, but note that it doesn't work at the
interactive prompt, only in a real source file.)

(The fact that I felt obliged to add the first paragraph on that page is
the funniest part of the whole thing. I really did have people genuinely
thanking me for the module, asking for features, asking for help with
using it, and so on.)


That module is. . .
a) impressive
b) very, very, wrong
c) both a) and b)

I think I'm voting for c). . .

Cheers,
Nick.

--
Nick Coghlan | nc******@email.com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
Jul 18 '05 #24

This discussion thread is closed

Replies have been disabled for this discussion.