Computing.Net > Forums > Linux > single passwd command

single passwd command

Reply to Message Icon

Original Message
Name: John
Date: August 4, 2002 at 14:48:54 Pacific
Subject: single passwd command
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


Report Offensive Message For Removal


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


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


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: single passwd command

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 6 Days.
Discuss in The Lounge