[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell Script on Debian



Hi,
There is another way... Here's my way to do it:
copy and paste this command:

$ cat > chpass << EOF
#!/bin/sh
# \\
exec expect -f "\$0" \${1+"\$@"}
set password [lindex \$argv 1]
spawn passwd [lindex \$argv 0]
sleep 1
expect "assword:"
send "\$password\r"
expect "assword:"
send "\$password\r"
expect eof
EOF


Then issue this command:
$ chmod +x chpass


to test it, just try this command:
$ ./chpass <username> <newpassword>

for example:
root@mydebian:root# /root/chpass root mynewrootpass
spawn passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@mydebian:root#

Good Luck!!



On Fri, Jun 27, 2008 at 12:45 PM, Phuong Phan Thi Bach
<ptbphuong@selab.hcmuns.edu.vn> wrote:
> Hello,
> The  "passwd" command expects to read the new password only from the
> console, How to it read the new password only from a file.  I create a file
> (Ex: test file )
>
> test file
> 123456
> 123456
> After, I use: "passwd < test" (shell on Debian is sh)
> But it always error: "Enter new UNIX password: Retype new UNIX password:
> Sorry, passwords do not match"
> Please, could you help me.
> Best regards,
> Phuong
>



-- 
Best Wishes,

ApOgEE a.k.a JeRuNgKuN
----------------------------------------------------
https://edge.launchpad.net/~apogee - ApOgEE on LaunchPad
http://artofapogee.blogspot.com - Art Of ApOgEE
http://coderstalk.blogspot.com - Coder's Talk
http://jerungkun.blogspot.com - The Rojak Blog
http://reggae-and-ska.blogspot.com - Reggae and SKA Music Blog
----------------------------------------------------


Reply to: