Reputation: 883
I am currently writing a bash script and when i run the useradd command it requires 2x input. What is the command to input from the bash script into the prompted password fields from useradd?
Upvotes: 1
Views: 781
Reputation: 297265
If the input is being read from stdin, you could do this;
useradd <<EOF
first input
second input
EOF
Some programs, however, do not read from stdin precisely to stop this kind of thing.
Edit
As remarked upon, this is called a "HERE document", in case you want to look it up.
Upvotes: 1
Reputation: 4425
I can't be bothered booting up my Linux system to check, but does the useradd program still prompt if you pass the information on the command line?
useradd -m -p encryptedPassword username
Upvotes: 0