shell command needs whitespace characters escaped

Klaus Alexander Seistrup klaus at seistrup.dk
Fri Dec 8 11:51:23 EST 2006


Metaperl wrote:

> I downloaded a file which has a space in the filename. I want 
> to run a shell unzip on it, but it fails in my current code:
>
>         syscmd = "cd %s ; unzip %s" % (self.storage.input, file.basename())
>         os.system(syscmd)
>
> because no escaping was done.

Using "cd '%s' ; unzip '%s'" as your formatting string should work.

Cheers,

-- 
Klaus Alexander Seistrup
http://klaus.seistrup.dk/



More information about the Python-list mailing list