Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python from the command line (was: Choosing Perl/Python for my particular niche)

Reply
Thread Tools

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

 
 
Cameron Laird
Guest
Posts: n/a
 
      04-01-2004
In article <(E-Mail Removed)>,
Fred Ma <(E-Mail Removed)> 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 <(E-Mail Removed)>
Business: http://www.Phaseit.net
 
Reply With Quote
 
 
 
 
Fred Ma
Guest
Posts: n/a
 
      04-01-2004
Cameron Laird wrote:
>
> In article <(E-Mail Removed)>,
> Fred Ma <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Cameron Laird
Guest
Posts: n/a
 
      04-01-2004
In article <(E-Mail Removed)>,
Fred Ma <(E-Mail Removed)> 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 <(E-Mail Removed)>
Business: http://www.Phaseit.net
 
Reply With Quote
 
Fred Ma
Guest
Posts: n/a
 
      04-01-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
is there a gem command to open up the rdoc for a particular gem inthe default browser at the index page??? Greg Hauptmann Ruby 2 11-08-2008 08:08 PM
Choosing the path based on the system "uname" command doni Perl Misc 6 03-05-2007 12:31 AM
Run Unix shell command $ parse command line arguments in python rkoida@yahoo.com Python 4 04-23-2005 04:42 AM
Python from the command line (was: Choosing Perl/Python for my particular niche) Cameron Laird Perl Misc 2 04-01-2004 12:50 PM
RUN/execute a Command-Line command from an ASP page. Lucas Cowald ASP .Net 4 10-23-2003 11:09 AM



Advertisments