how to write a shell script to take password automattically after the execution of command

#!/bin/bash
cd /var/SUNWdsee/ds6/bin
./dsconf show-repl-agmt-status -e suffix Hostname:389

Above is my script. After the execution of the last line it will prompt for password in screen.

I need to know how can we automatically populate password after the command execution (./dsconf show-repl-agmt-status -e suffix Hostname:389).

Answer

Try giving that as input

echo "Any#PasSwD" > .passwd.txt
./dsconf show-repl-agmt-status -e suffix Hostname:389 < .passwd.txt

If the above works, you can even try the below

./dsconf show-repl-agmt-status -e suffix Hostname:389 | echo "Any#PasSwD"

Attribution
Source : Link , Question Author : Vasanthshankar , Answer Author : sureshraju

Leave a Comment