$
$
$ # contents of myscript.sh
$ cat -n myscript.sh
1 #!/usr/bin/bash
2 echo "Printing from myscript.sh"
3 echo -n "Enter password: "
4 read passwd
5 echo
6 echo "Your password is: $passwd"
7 echo "End of myscript.sh"
$
$ # run myscript.sh and feed password when prompted
$ ./myscript.sh
Printing from myscript.sh
Enter password: hello_world
Your password is: hello_world
End of myscript.sh
$
$ # now put the password in a file, say "mypasswd.txt"
$ cat -n mypasswd.txt
1 hello_world
$
$ # and call myscript.sh, redirecting the password from mypasswd.txt
$ ./myscript.sh < mypasswd.txt
Printing from myscript.sh
Enter password:
Your password is: hello_world
End of myscript.sh
$
$
Im running my command using "pbrun", so the password is required by system .. I want to automate providing my password to the system each time it asks me
when I run:
$ pbrun commands
the system will ask me to provide my pbrun password
Right, but does it work if you put your password in a file and redirect from it? If not, then explain how you set it up, how you invoked your script, and what exactly you see when the script is run.