Sponsored Content
Full Discussion: password changing
Top Forums Shell Programming and Scripting password changing Post 302641681 by bakunin on Wednesday 16th of May 2012 11:34:48 AM
Old 05-16-2012
First off, i think you are reinventing the wheel. Have a look at the passwd command, which does what you want already in a much better way than you could ever dream of in some shell script.

Quote:
Originally Posted by somersetdan
Code:
sed 's/$pin/$npass/' usernames

This will never work, because inside single quotes variables are not becoming expanded. You are searching for a literal "$pin" instead of the contents of the variable "pin".

To write sed output to a file just redirect its output to it. If you want to overwrite your old file move the output over the input afterwards (reasons explained):

Code:
sed '<some operations>' /path/to/input > /path/to/output
mv /path/to/output /path/to/input

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Password Changing With NIS

SCO OpenServer 5.05 Has anyone ever received this error when attempting to change/assign a user password? #ypasswd ======================================= yppasswd: (host name) is not running yppasswd daemon Password request denied. Reason: Remote password change request denied.... (2 Replies)
Discussion started by: gseyforth
2 Replies

2. Solaris

changing password

Hi Someone logged on the system with a Normal user and changed the password , for this user , how can i know ? who changed the password from which terminal ? regards Georges (5 Replies)
Discussion started by: itsgeorge
5 Replies

3. UNIX for Dummies Questions & Answers

Changing password is to short ?

Hello im trying to change the user password with passwd but when I enter the password it gives me this msg: passwd: Password too short - must be at least 6 characters. BUT the thing is that the initial password was 4 letters why now it asking for 6 ? tnx (2 Replies)
Discussion started by: umen
2 Replies

4. AIX

changing user password

I have 02 servers: - Linux RHEL AS 3 (server1) - AIX 5.2 (server2) Running the command rsh server2 passwd derje from the server1 to change derje user password on server2, give me this error: 3004-709 Error while changing the password for "derje" Can somebody help me ? (0 Replies)
Discussion started by: mayge
0 Replies

5. HP-UX

Changing root password

I have two unix system A and B with same configuration. I can use remsh from A system login to B system as root, but when I want to change the root password of B system, it ask me the old password, but i forgot it. However, is it possible to change the B system root password? :( Thanks a lot (3 Replies)
Discussion started by: zetadhell
3 Replies

6. Solaris

Changing Password in NIS

Friends I want to know whether i can change the password of a user logged in thru NIS from a client machine after stopping the YP services in NIS server. Note - The Slave server is up and running. I tried doing this. But i got the reply "Permission Denied". I stopped the YP services in... (7 Replies)
Discussion started by: efunds
7 Replies

7. Linux

Problem changing user password

Hi all, I'm having an issue resetting an Linux user password. As root, I type 'passwd <username>, enter the new password, but the user is still Access Denied. Can someone assist me in figuring this one out? The box is running "Linux trm62 2.4.21-15.ELsmp #1 SMP Thu Apr 22 00:18:24 EDT 2004... (6 Replies)
Discussion started by: bbbngowc
6 Replies

8. Solaris

Solaris user changing password

i created 1 user . Now its passwd time period get expired. Now how can I set password for that user. Also how can I set a condition such a way that after every 3 months user must change his passwd. (5 Replies)
Discussion started by: ajitkraj
5 Replies

9. UNIX for Advanced & Expert Users

Changing the password prompt

Is there any way I can change the prompt which asks for the password on a UNIX system? e.g. When I login using Telnet instead of "Password" I should get "Correct Password". Thanks, Vineet (3 Replies)
Discussion started by: vineetd
3 Replies

10. AIX

Changing root password

I want to change the root password on an AIX box. What is the best method to do this so i do not get myself locked out. When I do i search the results come up for resetting the password if you are locked out. Thanks (5 Replies)
Discussion started by: fierfek
5 Replies
WESTCOS-TOOL(1) 						   OpenSC tools 						   WESTCOS-TOOL(1)

NAME
westcos-tool - utility for manipulating data structures on westcos smart cards SYNOPSIS
westcos-tool [OPTIONS] DESCRIPTION
The westcos-tool utility is used to manipulate the westcos data structures on 2 Ko smart cards. Users can create PINs, keys and certificates stored on the token. User PIN authentication is performed for those operations that require it. OPTIONS
--reader, r num Use the given reader. The default is the first reader with a card. --wait, -w Wait for a card to be inserted --generate-key, -g Generate a private key on smart card. The smart card must be not finalized and a PIN must be installed (ie. file for PIN must be created, see option -i). By default key length is 1536 bits. User authentication is required for this operation. --overwrite-key, -o Overwrite the key if there is already a key on card. --key-length length, -l length Change the length of private key, use with -g. --install-pin, -i Install PIN file in token, you must provide PIN value with -x. --pin-value value, -x value set value of PIN. --puk-value value, -y value set value of PUK (or value of new PIN for change PIN command see -n). --change-pin, -n Changes a PIN stored on the token. User authentication is required for this operation. --unblock-pin, -u Unblocks a PIN stored on the token. Knowledge of the PIN Unblock Key (PUK) is required for this operation. --certificate file, -t file Write certificate file in PEM format to the card. User authentication is required for this operation. --finalize, -f Finalize the card. Once finalized the default key is invalidated so PIN and PUK can't be changed anymore without user authentication. Warning, un-finalized are insecure because PIN can be changed without user authentication (knowledge of default key is enough). --read-file path, -j path Get the file path the file is written on disk with path name. User authentication is required for this operation. --write-file path, -k path Put the file with name path from disk to card the file is written in path. User authentication is required for this operation. --help, -h Print help message on screen. -v Causes westcos-tool to be more verbose. Specify this flag several times to enable debug output in the OpenSC library. AUTHORS
westcos-tool was written by Francois Leblanc francois.leblanc@cev-sa.com. opensc 06/03/2012 WESTCOS-TOOL(1)
All times are GMT -4. The time now is 06:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy