Looking for a scripting language

Peter Hansen peter at engcorp.com
Sun May 5 08:34:48 EDT 2002


deckerben wrote:
> 
> Peter Hansen" <peter at engcorp.com> wrote:
> > Try this:
> >
> > Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
> > >>> import os
> > >>> os.system('dir *.bat')
> 
> I'm in love. Yes, you read my mind.. 

Ah, shucks (blushing, kicks dirt).... oh, wait, you meant _with Python_?!

> this is just what I wanted. And it works (even using my DOS hack).

You might check if this works too, then:

>>> import os
>>> cmdOutput = os.popen('dir *.bat')
>>> text = cmdOutput.read()
>>> cmdOutput.close()
>>> print text

 Volume in drive C is DRIVE1-1
 Volume Serial Number is 2E17-18E1
 Directory of C:\

AUTOEXEC BAT           577  01-23-02  9:12p AUTOEXEC.BAT
TEST     BAT           146  03-13-02  9:02p test.bat
         2 file(s)            723 bytes
         0 dir(s)          269.93 MB free

Then you can do all kinds of neat analysis of the stdout results
of running the program.  Other more sophisticated options follow
on the heels of that experiment.

> > I thought you wanted to rewrite some batch files, but now you are
> > more concerned about future employment potential?
> 
> Just trying to think on practical terms :-)

I think you might have the employment thing nailed already.
Anyone who writes ports of Python and Javascript to DJGPP just
to experiment with which would make a more suitable replacement
for DOS batch files doesn't need to learn Perl to get access to
the widest range of jobs possible.  You should probably be able
to walk in to any reasonable company and tell them why they
should hire you and have them say "You're right... how much did
you say you wanted?".  (Well, maybe not quite, but that's how
the world _should_ work. :-)

Enjoy Python.

-Peter



More information about the Python-list mailing list