problem using subprocess.call

A

Alex Kachanov

Hi!
running py module with the following code from shell:
__
dir=os.path.join(os.path.expanduser("~/domains/domain.com/html"),'test')
subprocess.call(['find',dir+" -name '*.zip' -execdir unzip {} \;"])
__
returns:
__
find: /home/clients/alex291_ftp0/domains/domain.com/html/test -name
'*.zip' -execdir unzip {} \;: No such file or directory
__

Maybe I should change some escape-symbols? Which of them?
Tricks with
r"..."
"""..."""
\\
didn't help...
 
F

Fredrik Lundh

Alex said:
running py module with the following code from shell:
__
dir=os.path.join(os.path.expanduser("~/domains/domain.com/html"),'test')
subprocess.call(['find',dir+" -name '*.zip' -execdir unzip {} \;"])

subprocess.call(["find", dir, "-name", "*.zip", "-execdir", "unzip", "{}", ";"])

</F>
 
A

Alex Kachanov

dir=os.path.join(os.path.expanduser("~/domains/domain.com/html"),'test')
subprocess.call(['find',dir+" -name '*.zip' -execdir unzip {} \;"])

subprocess.call(["find", dir, "-name", "*.zip", "-execdir", "unzip",
"{}", ";"])

Ok, thanks, it works.
But what's the difference? Why I can't pass all parameters as one string?
 
F

Fredrik Lundh

Alex said:
subprocess.call(["find", dir, "-name", "*.zip", "-execdir", "unzip", "{}", ";"])

Ok, thanks, it works.
But what's the difference? Why I can't pass all parameters as one string?

because there's no one around to split them up for you.

after all, that's the whole point of running another program without going though the
shell: what you pass in ends up, as is, in the other program's argument array.

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top