0

How can I get the output of subprocess to append a list in the format as per my code below. I have searched this site but could not find a clear answer

import subprocess

stafflist = 'staff.text' 

passfile =[] # Generated from passgen_64

newDate = str(input('Enter new expiry date "Format = yyyy-mm-dd" '))

train_accounts = []

newAccounts = []

userFile = []

with open(stafflist) as file_object:

    lines = file_object.readlines()

for line in lines:

    if line.startswith('train'):
        train_accounts.append(line.rstrip().split(':'))
        pgen=subprocess.call(['/usr/bin/passgen_64'])
        passfile.append(pgen)
print (passfile)

Input :2020-11-11

YnJ1dHJhbGF0cmE=

amE5NXN0eWJydXJp

c3R5ZHJ1c3Rv

cHJ1Z3Jhdmk=

YnJ1Z3JpZHJl

Output : [0, 0, 0, 0, 0]

which is not I want, I need passfile to be: ['YnJ1dHJhbGF0cmE=','amE5NXN0eWJydXJp','c3R5ZHJ1c3Rv','cHJ1Z3Jhdmk=','YnJ1Z3JpZHJl']

AJD
  • 31
  • 3
  • Don't link to your code - add it to your question. – franiis Aug 21 '18 at 07:36
  • 1
    Please - format your code, add output to question. Present some effort and create question so someone would want to answer it. https://stackoverflow.com/help/how-to-ask – franiis Aug 21 '18 at 08:30
  • Possible duplicate of [read subprocess stdout line by line](https://stackoverflow.com/questions/2804543/read-subprocess-stdout-line-by-line) – tafaust Aug 21 '18 at 08:43

0 Answers0