LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-11-2010, 03:35 PM   #1
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Rep: Reputation: 31
non-interactive way to set a password?


Is there a non-interactive way to change a user's passwd short of using expect? I'm using Debian.

If not, then I guess I need to get this expect script working:

Code:
#!/usr/local/bin/expect -f 
set username $env(UNAME) 
set password $env(UPASS) 
spawn passwd $username 
expect "New password:" 
send "$password\r" 
expect "Re-enter new password:" 
send "$password\r" 
send "exit\r" 
expect eof
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 08-11-2010, 03:57 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
sure, just use chpasswd for one method.
 
2 members found this post helpful.
Old 08-11-2010, 04:06 PM   #3
davidstvz
Member
 
Registered: Jun 2008
Posts: 405

Original Poster
Rep: Reputation: 31
I just tested:

Code:
echo "username:newpass"|chpasswd
And it does the job just fine. You'd think that would turn up more easily in a Google search.


I had just got my expect script working (still wasn't flawless because it paused at the end which would add up and be annoying during a long script with 500+ users). I guess I'll post this Debian Lenny specific passwd expect for reference. Not much use now, but:

Code:
#!/usr/bin/expect -f
set username [lindex $argv 0]
set password [lindex $argv 1]
spawn passwd $username
expect "New Password:"
send "$password\r"
expect "Reenter New Password:"
send "$password\r"
expect "Password changed."
expect "passwd: password updated successfully"
expect eof
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How are variables set for interactive shells? Josh000 Slackware 22 05-07-2010 12:19 AM
Permission denied (publickey,password,keyboard-interactive) cccc Linux - General 3 05-31-2007 05:32 PM
Permission denied (publickey,password,keyboard-interactive). rockymaxsource Linux - Networking 3 04-27-2007 08:32 PM
interactive password manager XicKy Linux - Software 2 11-08-2006 11:49 AM
Need to set up online interactive spreadsheets. sdolin Linux - Newbie 1 04-13-2006 03:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration