I’m trying to setup python fabric for postgresql, but can’t figure out how to input the new password at the prompt. How do you set up the following in fabric:
sudo passwd –d postgres
sudo su postgres –c passwd
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Solution 1:
What I am writing here is a bad hack from the security perspective.
It provides the password on the command line hence it should not be used any where apart from toy work:
PS: This solution uses older formatting technique. That should not detract you from using newer one.
Solution 2:
Passwd expects input from stdin, you can instead use pexpect / expect to do this work exclusively and is better approach than the above but not without it’s flaws.
Sample pexpect program: