Computing.Net > Forums > Linux > single passwd command

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

single passwd command

Reply to Message Icon

Name: John
Date: August 4, 2002 at 14:48:54 Pacific
Comment:

is it possible to do a single password command in linux like in unix

echo password | passwd username --stdin

I tried compiling expect but it didn't like that to much. does anyone know of a way to do this


John
--slackware 8.1



Sponsored Link
Ads by Google

Response Number 1
Name: junky_toof
Date: August 5, 2002 at 01:25:03 Pacific
Reply:


Hi John.

You can get the latest version of expect and tcl/tk in a ready to install package
at www.activestate.com. Very simple.
Just uninstall your old tcl/tk/expect
junk first to save yourself some hassle.

#!/usr/bin/expect

set pprpmt ".*asswor.*"
set user [lindex $argv 0]

proc newpass {} {
puts -nonewline stdout "New Password: "
flush stdout
stty -echo
if {![catch {set p [gets stdin]}]} {
stty echo
return $p
}
return 1
}


spawn passwd $user
set id $spawn_id

expect {

-re "$pprmpt" {
set pass [newpass]
send "$pass\r"
expect {
-re "$pprmpt" {
send "$pass\r"
catch {unset pass}
}

eof {
send_user "All done\n"
exit
}
}
}
}

call like:
newpass.exp $username

HTH


0
Reply to Message Icon

Related Posts

See More


How do you set up a TFTP ... RHL 7.3 / XP dual boot pr...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: single passwd command

I loss my root password www.computing.net/answers/linux/i-loss-my-root-password/21042.html

Tech Company Locked Server. www.computing.net/answers/linux/tech-company-locked-server/28828.html

linux www.computing.net/answers/linux/linux/504.html