2

Hi I have below python script with below line

Script name :   add_cert.py

keytool -keystore client.truststore.jks -alias rby-yagpps -import -file rby-yagpps_1.crt
keytool -keystore client.truststore.jks -alias rby-yagpps -import -file rby-yagpps_1.crt
keytool -keystore client.truststore.jks -alias rby-yagpps -import -file rby-yagpps_1.crt
keytool -keystore client.truststore.jks -alias rby-yagpps -import -file rby-yagpps_1.crt

with each line executing by script , it asking password , i have same password for all of the above lines

how to input password automatically without manual intervention ?

2 Answers 2

1

Maybe you could try pexpect. It is designed to deal with interactive programs, which seems to be your case.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use pexpect to automate this process. You can use these examples.

a small example of how this might look.

child = pexpect.spawn('./add_cert.py')
child.expect('enterpassword') # This is a regex searching for print statement of script
child.sendline('yourpassword')
# repeat your process so long as the `expect` is `enterpassword`

You could figure out some kind of loop that is particular to your case so that it does it efficiently.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.