PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : python3 subprocess falscher Output



Huhn Hur Tu
29.12.16, 12:14
http://pastebin.com/fS2S5YEE

Statt des aus der Datenbank ausgelesenen Wertes, bekomme ich nur folgendes

- <subprocess.Popen object at 0x7f954fbc1dd8>

wenn ich die Variable db_out1 printe, jedoch ohne stdout=subprocess.PIPE wird der Wert als Stdout auf die Konsole geworfen

snowcrash23
31.12.16, 19:43
Moin! Die Python Doku sagt zu subprocess.Popen:

The recommended way to launch subprocesses is to use the following convenience functions. For more advanced use cases when these do not meet your needs, use the underlying Popen interface.

Versuch es mal mit

db_output = subprocess.check_output([sqsh_path, '-S', db_server, '-D', db_schema, '-C', db_statement], stdout=subprocess.PIPE)

Ich Hoffe das hilft.


MfG
snowcrash23!

Huhn Hur Tu
02.01.17, 07:16
Ueder das ICR habe ich folgendes bekommen



db_output = subprocess.Popen([sqsh_path, '-S', db_server, '-D', db_schema, '-C', db_statement], stdout=subprocess.PIPE).communicate()


Das ".communicate" hat dafuer gesorgt, dass ich nicht mehr die subprocess meldung, sondern den Wert

- b'5056\n'

bekomme. Hm.. ich hoffe, dass mir das spaeter nicht um die Ohren fliegt.

Gruss Stefan