Simulate user input in bash script [closed]

You should find the ‘expect’ command will do what you need it to do. It’s widely available.

A very rough example:

#!/usr/bin/expect
set pass "mysecret"

spawn /usr/bin/passwd

expect "password: "
send "$pass"
expect "password: "
send "$pass"

Leave a Comment