python call external program FINISHED!

Ben Thomas bthomas at trey-industries.com
Thu Sep 16 09:25:38 EDT 1999


I thought I would post my working script here so others can make fun of it,
I mean look at it if they are just starting out. I intend to use the
scheduler and FTP to automate and send offsite a copy of our data every
night.

so far python looks pretty cool;
Ben


*****************************************************************************

from string import *
from DateTime import *
from os import *

system('map root t:=server1\\vol1:prog_w31\\vacman')
system('xcopy t: d:\\data\\vacman\\temp\\ /e ')

timestamptext = now()
timestamptext = str(timestamptext)
timestamptext = replace(timestamptext, ' ', '_at_')
timestamptext = replace(timestamptext, ':', '_')
timestamptext = replace(timestamptext, '.', '_')
timestamptext = 'd:\\data\\vacman\\dc_vacman_' + timestamptext

vac_zip = 'pkzip -a -m -p -r ' + timestamptext + '
d:\\data\\vacman\\temp\\*.*'
#print 'here is zip command string:  ' + vac_zip
#I used pkzip DOS 2.5 , watch recyled bin may get full

#why do I need to cast this value as a string if it already is, I think this
may be extra
vac_zip = str(vac_zip)

system(vac_zip)

system('map del t:')
*****************************************************************************

Ben Thomas wrote:

> very simple question:
>
> What would I do to have Python execute something from the DOS command
> line. I am very new to python but I bet it is in a moudule but don't
> know the command or the modules to look in. I want to
>
> dir >%myvar.txt
>
> #this code would run dir from the command line and pass the var "myvar"
> , dir would dump a listing of the files into a text file called xxxx.txt
>
> pointers?
>
> Ben





More information about the Python-list mailing list