Operating System - HP-UX
1752682 Members
5776 Online
108789 Solutions
New Discussion юеВ

Re: change character in the passwd file

 
Jocelyn Dinel
Occasional Advisor

change character in the passwd file

i want to change the following

cafeteri::4397:30:Cafeteria:/users/cafe:/bin/sh
by
cafeteri:,..:4397:30:Cafeteria:/users/cafe:/bin/sh
i have some other user with the same case no passwd. i tried a lot of things with cut and tr but never be able to do the right thing.
tanx to answer me
jocelyn dinel
14 REPLIES 14
R.K. #
Honored Contributor

Re: change character in the passwd file

To edit passwd file use "vipw".
Don't fix what ain't broke
Jocelyn Dinel
Occasional Advisor

Re: change character in the passwd file

no i know the command vi,

i want a program to check regularly if a user don't have password et put :,..: at the place

tanx
jocelyn dinel
OldSchool
Honored Contributor

Re: change character in the passwd file

"no i know the command vi,"


ok, you know "vi", but "vipw" *is* vi for use w/ the password file, and is what should be used.




"i want a program to check regularly if a user don't have password et put :,..: at the place"


Lets start with what you hope to accomplish by making that substitution. It appears to me (and I could well be mistaken) the the password is still left unset and the password aging stuff is disabled.

Depending upon your answer, its conceivable that this could be done with the "password" command and "expect" as well. Also, if this is occuring frequently, you've other issues, such as "How come the password isn't set?"

OS version would be helpful. The system doesn't appear to be in trusted mode...Is that correct?
Jocelyn Dinel
Occasional Advisor

Re: change character in the passwd file

tanx my friends for the answer,

the problem is the following, by default i have a program who control the aging of the passwd file and it works properly, i know the aging by unix but the organisation want to write a french message with the change of the password so i construct a program for the aging, but

i use shadowing for better protection and sometimes for the use of another special program i have to return with no-shadowing.

and in this case the aging like :,..: return to :: it's the reason i want a little program to add in this program to not let my password file without password.

i use 11i for the version
jocelyn dinel
OldSchool
Honored Contributor

Re: change character in the passwd file

"....it's the reason i want a little program to add in this program to not let my password file without password."

but, unless I'm mistaken, setting it to ":,..." *does* leave the passwd unset. would not it look something like "asdaksd,..." if there were a password?
Jocelyn Dinel
Occasional Advisor

Re: change character in the passwd file

no,

when we create a new employe, by default we let the user put the password they want, so it's the reason i want to put :,..: when we returned with no-shadow passwd
jocelyn dinel
OldSchool
Honored Contributor

Re: change character in the passwd file

hmm...well, I would have assigned a default password and made them change it on first login...which probably would prevent this, but to each their own.

awk can help you out...

awk.scr:
========================
BEGIN{
FS=":";
OFS=":";
}

{
if ($2 == "")
{$2=",..";
print $0;
}
}
=====================

will find any lines with :: after the login name. you'd run it like the following

awk -f awk.scr /etc/passwd > (temp file here)

further refinements are possible (and recommended) to apply it to a list of ids or whatever
Jocelyn Dinel
Occasional Advisor

Re: change character in the passwd file

tanx my friend,

i'll try it on my test machine

have a good week-end
jocelyn dinel
Jocelyn Dinel
Occasional Advisor

Re: change character in the passwd file

i execute the program,
the result is exactly what i need.

Is it possible to have this result directly in the passwd file?

tanx again
jocelyn dinel