python call external program (WHAT THE?!)

Phil Hunt philh at vision25.demon.co.uk
Tue Sep 14 19:37:27 EDT 1999


In article <65118AEEFF5AD3118E8300508B124877073BF5 at webmail.altiris.com>
           MSteed at altiris.com "Mike Steed" writes:
> > From: Ben Thomas [mailto:bthomas at trey-industries.com]
> > Sent: Tuesday, September 14, 1999 9:31 AM
> > To: python-list at python.org
> > Subject: Re: python call external program (WHAT THE?!)
> > 
> > 
> > I just tried but putting the batch file in three places on a 
> > drive. The I tried
> > them all.
> > 
> > system('d:\mybat.bat') = ok
> > system('d:\data\mybat.bat') = ok
> > system('d:\data\vacman\mybat.bat') = fails, it works fine 
> > from DOS prompt!
> > 
> > 
> > what gives?
> > Ben
> 
> What gives is that \v is an escape code (representing, I believe, the ASCII
> VT character).  There are a few ways around this.
> 
> # Use raw strings
> system(r'd:\data\vacman\mybat.bat')
> 
> # Escape your backslashes
> system('d:\\data\\vacman\\mybat.bat')
> 
> # Use forward slashes (at least this works on WinNT)
> system('d:/data/vacman/mybat.bat')

You missed out:

# use Linux instead of MS rubbish
system('/usr/local/data/myshell.sh')

-- 
Phil Hunt - - - - - - - - -  philh at vision25.demon.co.uk
 - Linux will be 8 years old on 17th September! See: -
http://www.vision25.demon.co.uk/prog/linuxbirthday.html





More information about the Python-list mailing list