Problems executing commands with (') character in python -


i'm doing program copies files music playlist. execute command this:

command =   'cp "%s" "%s"' % (songpath,plpath) os.system(command) 

the problem when execute if song's path has ' character command can not executed. says:

cp: cannot stat `/home/myname/music/oasis/(what\'s story) morning glory/03 wonderwall.mp3': no such file or directory

i checked songpath , has no \ character before ' know how avoid program adding \ character?

thank in advance!

use subprocess.call instead:

ret_val = subprocess.call(['cp',songpath,plpath]) 

this avoids shell arguments should passed cp in exact form gave them.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -