Is Python as capable as Perl for sysadmin work?

Discussion in 'Python' started by John M. Gabriele, Feb 8, 2005.

  1. 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 ---
     
    John M. Gabriele, Feb 8, 2005
    #1
    1. Advertising

  2. John M. Gabriele

    Guest

    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.
     
    , Feb 8, 2005
    #2
    1. Advertising

  3. 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 ---
     
    John M. Gabriele, Feb 8, 2005
    #3
  4. John M. Gabriele

    Aahz Guest

    In article <>,
    John M. Gabriele <> 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 () <*> 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
     
    Aahz, Feb 8, 2005
    #4
  5. 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*
     
    Jeremy Bowers, Feb 8, 2005
    #5
  6. John M. Gabriele

    Roy Smith Guest

    In article <>,
    "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?
    >
    > 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.
     
    Roy Smith, Feb 8, 2005
    #6
  7. John M. Gabriele

    Nick Vargish Guest

    "John M. Gabriele" <> 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?')
     
    Nick Vargish, Feb 8, 2005
    #7
  8. 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 --
     
    John M. Gabriele, Feb 8, 2005
    #8
  9. Nick Vargish wrote:
    > "John M. Gabriele" <> 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 ---
     
    John M. Gabriele, Feb 8, 2005
    #9
  10. John M. Gabriele

    Jeff Epler Guest

    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+v9z5z3wTQCghTqH
    VKdS8hwqlr7zWdm8piCRdbY=
    =bbHJ
    -----END PGP SIGNATURE-----
     
    Jeff Epler, Feb 8, 2005
    #10
  11. 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
     
    Marc Huffnagle, Feb 8, 2005
    #11
  12. 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.
     
    Paddy McCarthy, Feb 8, 2005
    #12
  13. John M. Gabriele

    Peter Maas Guest

    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')
    -------------------------------------------------------------------
     
    Peter Maas, Feb 8, 2005
    #13
  14. John M. Gabriele

    Peter Maas Guest

    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')
    -------------------------------------------------------------------
     
    Peter Maas, Feb 8, 2005
    #14
  15. John M. Gabriele

    Max M Guest

    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
     
    Max M, Feb 9, 2005
    #15
  16. Jeff Epler <> 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 <> -- http://www.craig-wood.com/nick
     
    Nick Craig-Wood, Feb 9, 2005
    #16
  17. John M. Gabriele

    Roy Smith Guest

    In article <4209b8a4$0$223$>,
    Max M <> 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
     
    Roy Smith, Feb 9, 2005
    #17
  18. 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
     
    Steve Horsley, Feb 9, 2005
    #18
  19. John M. Gabriele

    Greg Ewing Guest

    Python as a machine tool (Re: Is Python as capable as Perl for sysadminwork?)

    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
     
    Greg Ewing, Feb 9, 2005
    #19
  20. John M. Gabriele

    Courageous Guest


    >> 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//
     
    Courageous, Feb 9, 2005
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Stromberg

    sysadmin -> python programmer

    Dan Stromberg, Jul 19, 2006, in forum: Python
    Replies:
    2
    Views:
    410
    fumanchu
    Jul 20, 2006
  2. walterbyrd
    Replies:
    2
    Views:
    291
    Brent Bloxam
    Aug 25, 2009
  3. Bogdan Jokel
    Replies:
    0
    Views:
    782
    Bogdan Jokel
    Jan 15, 2010
  4. Replies:
    0
    Views:
    106
  5. Thomas Rachel
    Replies:
    0
    Views:
    144
    Thomas Rachel
    Jan 24, 2012
Loading...

Share This Page