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?
3 Answers
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.
1 Comment
IRBMe
For the benefit of the author of th question, this is called a 'Here Document', in case you want to look it up.
try using expect:
Expect is a tool for automating interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, etc
expect works also for programs that do not read from stdin.
1 Comment
Daniel C. Sobral
I should have recalled that. I have used except for this precise reasons tons of time.