LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-14-2009, 06:14 PM   #1
manwithaplan
Member
 
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393

Rep: Reputation: 45
Dialog passwd suggestions


I have a script that adds the root passwd to an new install. It was written in dialog. My issue is that my passwd version doesn't support --stdin option. I need help with some sort of redirection and to pass crypted data to add the root user. I've read up on expect and it seems it wont fit with what I want to accomplish.

Any suggestions?

Code:
root_password() 
{

    PASSWORD=""
    PWD_MESSAGE1="Please enter a new root password or press Enter \
to keep the current root password. \
(Please note, an empty root password is NOT recommended !)"
    PWD_MESSAGE2="Retype new password:"

    while [ ! $PASSWORD ]; do
	    $DIALOG --backtitle $BTITLE --title "Root Passwd" --insecure  --no-cancel --passwordbox \
		"$PWD_MESSAGE1" 15 60 2>$OUTPUT
	    PASSWORD1=$( cat $OUTPUT )
	    rm -f $OUTPUT
	[ ! $PASSWORD1 ] && break
	    $DIALOG --backtitle $BTITLE --title "Root Passwd" --insecure  --no-cancel --passwordbox \
		"$PWD_MESSAGE2" 15 60 2>$OUTPUT
	    PASSWORD2=$( cat $OUTPUT )
	    rm -f $OUTPUT
	if [ "$PASSWORD1" = "$PASSWORD2" ]; then
	    PASSWORD=$PASSWORD1
	    echo $PASSWORD | passwd --stdin root >/dev/null
	
	fi
    done
    
}
 
Old 03-16-2009, 01:34 PM   #2
jan61
Member
 
Registered: Jun 2008
Posts: 235

Rep: Reputation: 47
Moin,

try chpasswd instead.

Jan
 
Old 03-16-2009, 02:00 PM   #3
manwithaplan
Member
 
Registered: Nov 2008
Location: ~/
Distribution: Arch || Sidux
Posts: 393

Original Poster
Rep: Reputation: 45
I wasnt familiar with chpasswd... thx for the help... I think this will work nicely
 
  


Reply



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
Function suggestions... and while loop isn't exiting in dialog manwithaplan Programming 1 03-13-2009 08:08 PM
Swat uses PAM but changes linux passwd not samba passwd Peter@KKVS Linux - Networking 0 11-26-2006 04:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:46 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
Open Source Consulting | Domain Registration