Python from the command line (was: Choosing Perl/Python for my particular niche)

Discussion in 'Python' started by Cameron Laird, Apr 1, 2004.

  1. In article <>,
    Fred Ma <> wrote:
    .
    .
    .
    >Perl/sed. About invoking Perl as part of a simple command in a
    >pipeline, I mean that one doesn't even have to write a script for it,
    >similar to sed
    >
    > Command1 | sed -e Expression1 -e Expression2 ... | Command_N
    >
    >This might also be possible in Python, in which case so much the better.
    >I'll find out (or someone might answer in a follow-up post). Thanks

    .
    .
    .
    # python -c "print 3 + 5"
    8
    --

    Cameron Laird <>
    Business: http://www.Phaseit.net
     
    Cameron Laird, Apr 1, 2004
    #1
    1. Advertising

  2. Cameron Laird

    Fred Ma Guest

    Re: Python from the command line (was: Choosing Perl/Python for myparticular niche)

    Cameron Laird wrote:
    >
    > In article <>,
    > Fred Ma <> wrote:
    > .
    > .
    > .
    > >Perl/sed. About invoking Perl as part of a simple command in a
    > >pipeline, I mean that one doesn't even have to write a script for it,
    > >similar to sed
    > >
    > > Command1 | sed -e Expression1 -e Expression2 ... | Command_N
    > >
    > >This might also be possible in Python, in which case so much the better.
    > >I'll find out (or someone might answer in a follow-up post). Thanks

    > .
    > .
    > .
    > # python -c "print 3 + 5"
    > 8


    I was 99.99% sure that it was possible (heck, if tcsh and bash can do
    it, python surely can). It's a little easier to squish it into a simple
    command in a pipeline for a terse/compact "language" e.g. sed. On a
    side-note, I've abused sed before by embedded sed scripts into bash
    scripts without actually writing the sed script:

    Bash_Command | \
    sed \
    -e 'Expression1' \
    -e 'Expression2' \
    -e 'Conditional1 {' \
    -e 'Body_of_Conditional1' \
    -e 'More_of_Body' \
    -e '}' \
    | More_Bash_Commands

    Not that I want to do everything in sed, of course. And for
    perl/python, there is probably not much reason to mix commands
    with bash, since (unlike sed) they have the shell functionality.

    I've put in a request to my sysadmin to install python. The
    way to get hooked on it is to start small, with mundane tasks
    (same as with any new shell, I suppose). If it doesn't get
    installed due to lack of priority, I can always get it
    bundled with my next cygwin update. Cygwin is an absolute
    blessing. Everything comes prebuilt (lots of stuff) and
    you have superuser priveleges, as well as simultaneous
    access to Windows. Just as long as your HDD isn't FAT
    (that prevents chmod from working).

    But I digress.....

    Fred

    --
    Fred Ma
    Dept. of Electronics, Carleton University
    1125 Colonel By Drive, Ottawa, Ontario
    Canada, K1S 5B6
     
    Fred Ma, Apr 1, 2004
    #2
    1. Advertising

  3. Re: Python from the command line (was: Choosing Perl/Python for myparticular niche)

    In article <>,
    Fred Ma <> wrote:
    .
    .
    .
    >I've put in a request to my sysadmin to install python. The
    >way to get hooked on it is to start small, with mundane tasks
    >(same as with any new shell, I suppose). If it doesn't get
    >installed due to lack of priority, I can always get it
    >bundled with my next cygwin update. Cygwin is an absolute
    >blessing. Everything comes prebuilt (lots of stuff) and
    >you have superuser priveleges, as well as simultaneous
    >access to Windows. Just as long as your HDD isn't FAT
    >(that prevents chmod from working).

    .
    .
    .

    Oh! Apparently Win* is the platform of interest; that
    hadn't occurred to me.

    There's a LOT to say specifically on the topic of Python-
    for-Windows-system-administration. You might want to
    start with Mark Hammond's book.

    I'm no great fan of CYGWIN for my own use, although I
    certainly recognize it's been historically important.
    It occurs to me that perhaps we haven't made adequately
    clear how easy it is to install native Python on Windows.
    It should take less time doing it than talking about do-
    ing it. I'm not arguing with your approach; I just want
    to ensure we've been clear about the alternatives.

    Follow-ups narrowed.
    --

    Cameron Laird <>
    Business: http://www.Phaseit.net
     
    Cameron Laird, Apr 1, 2004
    #3
  4. Cameron Laird

    Fred Ma Guest

    Re: Python from the command line (was: Choosing Perl/Python for myparticular niche)

    Cameron Laird wrote:
    >
    > >I've put in a request to my sysadmin to install python. The
    > >way to get hooked on it is to start small, with mundane tasks
    > >(same as with any new shell, I suppose). If it doesn't get
    > >installed due to lack of priority, I can always get it
    > >bundled with my next cygwin update. Cygwin is an absolute
    > >blessing. Everything comes prebuilt (lots of stuff) and
    > >you have superuser priveleges, as well as simultaneous
    > >access to Windows. Just as long as your HDD isn't FAT
    > >(that prevents chmod from working).

    >
    > Oh! Apparently Win* is the platform of interest; that
    > hadn't occurred to me.
    >
    > There's a LOT to say specifically on the topic of Python-
    > for-Windows-system-administration. You might want to
    > start with Mark Hammond's book.
    >
    > I'm no great fan of CYGWIN for my own use, although I
    > certainly recognize it's been historically important.
    > It occurs to me that perhaps we haven't made adequately
    > clear how easy it is to install native Python on Windows.
    > It should take less time doing it than talking about do-
    > ing it. I'm not arguing with your approach; I just want
    > to ensure we've been clear about the alternatives.



    Actually, didn't mean to cause a great deal of confusion here,
    but solaris is the main platform. But I access solaris boxes
    from a PC. And since I have a mapped network drive, I can use
    PC tools to work on my unix files.

    I agree, installing stuff on windows is easy. My comment about
    cygwin is that it's even easier than easy. I just have to check
    off the Python box. That gives me opportunity to try it for
    small things.

    By no means am I comparing cygwin to other unix environments for
    the PC. I enjoy it out of convenience. Most of my stuff is on
    the solaris, and cygwin gives me a nice posix shell without
    leaving the windows environment.

    Fred
    --
    Fred Ma
    Dept. of Electronics, Carleton University
    1125 Colonel By Drive, Ottawa, Ontario
    Canada, K1S 5B6
     
    Fred Ma, Apr 1, 2004
    #4
    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. Cameron Laird
    Replies:
    2
    Views:
    126
    Cameron Laird
    Apr 1, 2004
  2. J Krugman

    A wide open niche in Perl publishing...

    J Krugman, Feb 15, 2005, in forum: Perl Misc
    Replies:
    8
    Views:
    117
    Charlton Wilbur
    Feb 17, 2005
  3. Replies:
    2
    Views:
    164
    Tad McClellan
    Mar 26, 2005
  4. Ting Wang
    Replies:
    3
    Views:
    199
    Paul Lalli
    Dec 13, 2005
  5. jeniffer
    Replies:
    6
    Views:
    950
Loading...

Share This Page