Python 2.6.9 (unknown, Mar 7 2016, 11:15:18)
[GCC 5.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import subprocess
>>> subprocess.check_call(['echo', 'hi'], stderr=sys.stdout)
echo: write error: Bad file descriptor
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/subprocess.py", line 488, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['echo', 'hi']' returned non-zero exit status 1
Questo comando, subprocess.check_call(['echo', 'hi'], stderr=sys.stdout)
, funziona bene in Python 2.7 e Python 3. Che cosa fa in modo diverso Python 2.6?Perché "subprocess.check_call (..., stderr = sys.stdout)" non funziona in Python 2.6?
Potrebbe essere un percorso o un permesso? '' Subprocess.check_call (['/ bin/echo', 'hi'], stderr = sys.stdout) 'funziona? – jDo
hm, sicuramente a che fare con il reindirizzamento di 'stderr', anche se non riesco a vedere rapidamente cosa è cambiato tra 2.6 e 2.7 in subprocess.py. –
@jDo che dà lo stesso risultato. Penso che se fosse un problema di autorizzazioni, sarebbe lo stesso su 2.6 e 2.7? –