python call external program (WHAT THE?!)

Mike Steed MSteed at altiris.com
Tue Sep 14 11:39:47 EDT 1999


> 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')

-Mike




More information about the Python-list mailing list