How can I create a shell script containing some commands which need user input, for example
#!/bin/sh
useradd test
passwd test
The passwd command needs some input (the password). Can I serve this input via the shell script? Thank you!
|
How can I create a shell script containing some commands which need user input, for example
The passwd command needs some input (the password). Can I serve this input via the shell script? Thank you!
| |||
|
feedback
|
|
The But see the man page for | |||||||
feedback
|
|
Normally not since most programs which require a password will not read from stdin as regular UNIX processes do. Instead they will try to read in the password from the controlling tty. If you want to script such applications you will have to use tools like expect. | |||
|
feedback
|
|
Example:
Source:
| |||||||||||
feedback
|
|
Use expect. An example here
| |||
|
feedback
|