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?
+1
A:
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.
Daniel
2009-07-21 17:18:59
For the benefit of the author of th question, this is called a 'Here Document', in case you want to look it up.
IRBMe
2009-07-21 17:23:20
+1
A:
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.
dfa
2009-07-21 17:26:51
I should have recalled that. I have used except for this precise reasons tons of time.
Daniel
2009-07-24 19:31:43
A:
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
IRBMe
2009-07-21 17:28:47