Operating System - HP-UX
1753428 Members
4984 Online
108793 Solutions
New Discussion юеВ

Re: Script to compare and update discrepancy within two text file

 
yc_2
Regular Advisor

Script to compare and update discrepancy within two text file

Hi,

I want to update the password field of the password file in one host by comparing with another host based on the login name.

If Awk can perform this, how should it go about as I normally use Awk to process single text file ? If not, what is the best tool to use ?


Thanks in advance,
YC
4 REPLIES 4
Vincenzo Restuccia
Honored Contributor

Re: Script to compare and update discrepancy within two text file

You can test "cut" or "sed".
Pedro Sousa
Honored Contributor

Re: Script to compare and update discrepancy within two text file

you can use cut to get the password field, and if you want to compare you can use diff.

If you need to replicate users between systems, you should check something about the product NIS+

good luck
Thierry Poels_1
Honored Contributor

Re: Script to compare and update discrepancy within two text file

Hi,

if you want to synchronize passwords between two servers you should consider using NIS+ (The Yellow Pages).
Fooling around with the passwd file is certainly not recommended.

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Steven Sim Kok Leong
Honored Contributor

Re: Script to compare and update discrepancy within two text file

Hi,

Are you using HP-UX trusted? Because if you are, the passwords would be shadowed in /tcb/files/auth/*. The script has to be tailored differently for an untrusted and a trusted system.

If you are uneasy with perl, the next best thing is using sed to perform password substitution.

If you are using untrusted HP-UX which has its encrypted passwords residing within /etc/passwd. For each userid in the new password file eg. /etc/passwd.new, if this same userid exists in /etc/passwd, then replace the password field in /etc/passwd.new with the password field in /etc/passwd for this particular user.

If you are using trusted HP-UX, For each userid in the new password file, you have to extract the 1st letter of the userid, cd to your new tcb directory ie. /tcbnew/files/auth/s (where s is the first letter of the userid), extract the encrypted password from the u_pwd field of the userid eg. /tcb/new/files/auth/s/steven and replace the password in the corresponding /tcb/files/auth/s/steven of the original tcb directory.

For passwords which are asterisk'ed ie. *, you have to take special care in your scripting that it does not get treated like a wildcard and result in undesirable results.

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com