I am using the call
method from the subprocess
module of Python to run a command in the terminal
subprocess.call(['cmd', 'pybot', 'AdminTests', '-v', 'LOGIN URL:_mylink', '-d', '.\\results'])
However my call currently opens a terminal inside of itself, essentially reopening, and then dose nothing at all. Why isn't it executing the rest of my command? I have tried passing my full command as a single string, I have added the shell
parameter to my call.. I have tried everything I can think of but nothing is making my Python script run this command in full.
Why isn't my command being ran in full?
Edit: The ouput of the code only opens the command line, then does nothing.
Image: http://imgur.com/S82Hqjk
'\\r'
means Carriage Return character. You need to escape \\
to mean it literally.
subprocess.call(['cmd', 'pybot', 'AdminTests', '-v', 'LOGIN URL:_mylink', '-d', '.\\results'])
or use raw string literal:
subprocess.call(['cmd', 'pybot', 'AdminTests', '-v', 'LOGIN URL:_mylink', '-d', r'.\results'])
BTW, you can omit .\\
if it means current directory.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.