To run a command in python, for Windows, I do:
import subprocess
subprocess.check_output(lsCommand, shell=True)
where lsCommand
is a list of strings that make up the bash command. This works, except when it contains some input with spaces in it. For example, copying + changing a name:
To try and do cp "test 123" test123
:
lsCommand = ['cp', 'test 123', 'test123']
subprocess.check_output(lsCommand, shell=True)
fails because it thinks I am trying to do cp "test" "123" test123
. Error (doing google storage stuff):
python: can't open file 'c:\GSUtil\gsutil.py cp -n gs://folderl/test': [Errno 22] Invalid argument
Then I try
subprocess.check_output('cp "test 123" test123', shell=True)
Same shit. Any ideas?