Error in os.system() python

Asked

Viewed 655 times

0

I have a script in python that needs to run other software multiple times, I’m trying to do this using the.system("command"), but this function always returns me -1 and does not work, I have tested even with simple commands.

PS am using python 2.7

  • Welcome to Overflow in English! If you can explain better the problem you have in particular and, if possible, show code you have done where this problem is. Your question is too broad, see Help Center How to Ask.

  • Which operating system you are trying to run your script on?

1 answer

2


You can use another Python routine, called subprocess.call.

It avoids many problems related to quotation marks and conventions between the different shells of operating systems. The command is passed using a list instead of a string, the first element being the command and the next parameters.

Example

import subprocess
subprocess.call(['Notepad.exe', 'C:\\temp\\test.txt'])

Browser other questions tagged

You are not signed in. Login or sign up in order to post.