Trouble with subprocess.Popen()

F

Fernando

Hi,

I'm having a very strange issue with subprocess.Popen. I'm using it
to call several times an external exe and keep the output in a list.

Every time you call this external exe, it will return a different
string. However, if I call it several times using Popen, it will
always return the SAME string. =:-O It looks like Popen is returning
always the same value from stdout, without recalling the exe.

This is my code:
------------------------------------------------------------------------------------------------------------------------------------
def get_key():

from subprocess import Popen, PIPE

args = [C_KEY_MAKER, '/26', USER_NAME, ENCRYPTION_TEMPLATE, '0', ]
process = Popen(args, stdout=PIPE)
output = process.communicate()[0].strip()
return output


print get_key() # Returns a certain string
print get_key() # Should return another string, but returns the
same!
 
D

Dennis Lee Bieber

Every time you call this external exe, it will return a different
string. However, if I call it several times using Popen, it will

Does it? Have you tried using a command line shell?
args = [C_KEY_MAKER, '/26', USER_NAME, ENCRYPTION_TEMPLATE, '0', ]
What on Earth am I doing wrong?!

Calling something that appears to take a line of user supplied
parameters for the purpose of generating a unique key -- a key
apparently based upon the arguments and you don't show us what those are
-- which should be identical for the same arguments. After all, if
putting the SAME arguments into a process results in different output,
you have a random number generator (and don't even need the arguments).

I presume, somewhere in the code, you have defined values for:
C_KEY_MAKER, USER_NAME, and ENCRYPTION_TEMPLATE.
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top