Python subprocess.Popen does not work with stdout -


i need implement external application calculate crc values modbus communication. executable requires input string , gives output this:

crc16 = 0x67ed / 26605 crc16 (modbus) = 0x7ced / 31981 

i call programm , afterwards type in input manually.

p = popen(["some_file.exe", "-x"], stdin=pipe) p.communicate("some_string") 

this working fine far.

however, want save output variable or (no file) further uses.

i know there stdout , stderr arguments, when typing

p = popen([file, "-x"], stdin=pipe, stdout=pipe, stderr=pipe) 

nothing happens @ all.

does has idea do?

thanks in advance.

ps: using python 2.7 on windows 7.

to output of ls, use stdout=subprocess.pipe.

proc = subprocess.popen('ls', stdout=subprocess.pipe) output = proc.stdout.read() print output 

obtained from: pipe subprocess standard output variable

note:

if use stdin pipe must assign value, in example:

grep = popen('grep ntp'.split(), stdin=pipe, stdout=pipe) ls = popen('ls /etc'.split(), stdout=grep.stdin) output = grep.communicate()[0] 

if value given console using pipe, must assign stdin value reading sys.stdin


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -