1

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: https://i.sstatic.net/2ce3C.jpg

1 Answer 1

1

'\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.

Sign up to request clarification or add additional context in comments.

7 Comments

I'm afraid that escaping the character didn't help, but I have amended my code :(
@Leon, Or ['pybot', ...] (no cmd at all)
I then get the error [ ERROR ] Parsing '-v' failed: Data source does not exist. which is better, but still not good. Why is trying to read an argument as a data source? Edit: Both of your changes result in the same error
@Leon, I don't know about pybot. BTW, does the command itself work w hen you issue the command in command line, not through python ?
No, this is a pybot problem! Thank you very much for solving my issue. :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.