[CentOS] [OT]: Passing password for a command on the fly

Fri May 16 08:42:31 UTC 2008
Luciano Rocha <strange at nsk.no-ip.org>

On Fri, May 16, 2008 at 09:38:17AM +0100, Mário Gamito wrote:
> Hi,
> 
> First things first, sorry for the off-topic, but I've already burned
> my eyes Googling and couldn't find the answer to what I need and I
> remembered asking here, because I'm a long time CentOS and its mailing
> list user.
> Again, my apologies.
> 
> I have this command to create an FTP account:
> 
> # pure-pw useradd mario -u 502 -g 502 -n 1000 -N 200 -d /home/pages/mario
> 
> This command asks for the password twice.
> 
> I need to pass the password (preferably without expect) so I can
> create the account without prompting.
> 
> If i run:
> 
> # echo secret | pure-pw useradd mario -u 502 -g 502 -n 1000 -N 200 -d
> /home/pages/gamito
> 
> It reads the first insertion, but asks for the second.
(echo secret; echo secret) | pure-pw ...

Or: echo -e 'secret\nsecret' | pure-pw

Or: pure-pw <<EOF
secret
secret
EOF

-- 
lfr
0/0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20080516/76c5bfe8/attachment-0005.sig>