0

I'm using Python 2.6. After checking the following link: Running shell command from Python and capturing the output Here is the code I plan to do:

 import subprocess # input: user email account # output: mailing list which contain the user as an owner def list_owners (usr_eml): p = subprocess.Popen(['/usr/lib/mailman/bin/find_member','-w'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) out, err = p.communicate(usr_eml) print out m_list_usr_on = out.split( ) print m_list_usr_on list_owners("my_email") 

The output of this code is simply empty. On the other hand, if I run the code

/usr/lib/mailman/bin/find_member -w my_email directly from the shell command, I got the desired results. Could you explain to me the possible reasons of it? Thank you!

    1 Answer 1

    2

    Try to add usr_eml after the -w:

    import subprocess # input: user email account # output: mailing list which contain the user as an owner def list_owners (usr_eml): p = subprocess.Popen(['/usr/lib/mailman/bin/find_member','-w',usr_eml], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) out, err = p.communicate() print out m_list_usr_on = out.split( ) print m_list_usr_on list_owners("my_email") 
    0

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.