简体   繁体   中英

*nice* in subprocess.call function not working

I tried

>>> import subprocess
>>> import os
>>> subprocess.call(["echo","Hello there"], env=os.environ)
Hello there
0
>>> subprocess.call(["nice", "19", "echo","Hello there"], env=os.environ)
nice: 19: No such file or directory
127
>>> subprocess.call(["nice", "19", "echo","Hello there"], env=os.environ, shell=True)
0
0
>>>

I don't understand why subprocess is not recognizing nice there

I have no issues running nice in my shell

$nice -n 19 echo 'hi there'

hi there

Looks like you forgot an argument with "-n" in your subprocess.call call. You probably meant

subprocess.call(["nice", "-n", "19", "echo", "Hello there"], env=os.environ)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM