I have this terminal command I need to run programmatically in Python:
awssaml get-credentials --account-id **** --name **** --role **** --user-name ****
It will first ask for your password, and then prompt you for a 2 factor authentication code. I have these as variables in python that I just need to pass through to the command.
This is what I tried:
argss=[str(password_entry.get()),str(twoFactorCode_entry.get())]
p=subprocess.Popen(["awssaml", "get-credentials", "--account-id", "****", "--name", "****", "--role", "****", "--user-name", ID_entry.get()],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
time.sleep(0.1)
out=p.communicate('n'.join(map(str,argss)).encode())
And when I run this the console prints out that the password was entered because it shows password: xxxxxxxxxxxx
, but it then stops execution and does not show the 2 factor code being passed.
Any ideas for where I am going wrong to get the 2 factor code also passed through? Both the password and 2 factor code are within the argss
variable. password_entry.get()
is the password and twoFactorCode_entry.get()
is the 2 factor code.