Reputation: 77
I have the following line in my script:
subprocess.call([r"robocopy", "\\\\stockholm\exam$\ \\\\stockholm\exam_temp$\ /e /move"])
Which fails when I run it as Robocopy thinks that the whole line is the source address and has no destination. Could someone tell me what's wrong with my syntax? If I run the same line in CMD (minus the extra \'s etc obviously) it works perfectly!
Many thanks, Chris.
Upvotes: 0
Views: 2701
Reputation: 147
you can pass a list - for e.g.
command_to_pass = ["robocopy", src, dst, extra_args]
call(command_to_pass)
Upvotes: 0
Reputation: 4461
You need to scape de \'s or use raw strings
subprocess.call([r"robocopy", r"\\stockholm\exam$\ \\stockholm\exam_temp$\ /e /move"])
Upvotes: 1
Reputation: 149
try to pass args as list, es.
subprocess.call([r"robocopy", "\\\\stockholm\exam$\","\\\\stockholm\exam_temp$\","/e","/move"])
I'm not not sure about extra \'s.
Upvotes: 0