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

C

Cameron Laird

.
.
.
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
 
F

Fred Ma

Cameron said:
.
.
.
.
.
.
# 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
 
C

Cameron Laird

.
.
.
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.
 
F

Fred Ma

Cameron said:
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
 

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
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top