AIXThis forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Below script has user names in text file as input. For this script, some users password reset is working and for others password is not reset. Need your help in fixing this script. All are local system user accounts.
Code:
#!/bin/ksh
for i in `cat users.txt`
do
if[`id $i >/dev/null 2>&1;echo $?` -eq 0]
then
echo $i:$i
echo "$i:$i" | chpasswd -c
chesec -f /etc/security/lastlog-a "unsuccessful_login_count=0" -s $i
chuser account_locked=false $i
else
printf "user: $i does not exist on this system\n"
fi
done
Last edited by geekslinux; 05-01-2017 at 05:44 AM.
Below script has user names in text file as input. For this script, some users password reset is working and for others password is not reset. Need your help in fixing this script. All are local system user accounts.
Code:
#!/bin/ksh
for i in `cat users.txt`
do
if[`id $i >/dev/null 2>&1;echo $?` -eq 0]
then
echo $i:$i
echo "$i:$i" | chpasswd -c
chesec -f /etc/security/lastlog-a "unsuccessful_login_count=0" -s $i
chuser account_locked=false $i
else
printf "user: $i does not exist on this system\n"
fi
done
Please use CODE tags when posting scripts. And we'll be happy to help...when you actually tell us what error(s)/message(s) you're seeing, what diagnostic information you have, etc. "Not reset" for some, doesn't tell us anything. What's the differences between the accounts that work and the ones that don't? Have you run the script with any sort of debugging? Tried to run the commands manually on those that didn't work, to see what happened???
This is the output of the script. NB the users are there but not sure from where it fetches "User x does not exist". For some users when they gave username and password they were able to login. For certain users when they enter password it says "permission denied"
This is the output of the script. NB the users are there but not sure from where it fetches "User x does not exist". For some users when they gave username and password they were able to login. For certain users when they enter password it says "permission denied"
So you're running a ksh script with ash? Why? And as asked previously, what happens when you take one of the users you're having problems with, and run the script commands manually??
Sorry. It's a typo, I am running it as ksh. When I reset the password manually it works for the user. But resetting using script it's not working. It's only for few users across 10 servers where I run the script. Not all the users have this problem.
Sorry. It's a typo, I am running it as ksh. When I reset the password manually it works for the user. But resetting using script it's not working. It's only for few users across 10 servers where I run the script. Not all the users have this problem.
Then the problem isn't in the script; there's a difference in the users, somewhere.
Quote:
Originally Posted by geekslinux
NB the users are there but not sure from where it fetches "User x does not exist".
That's the output from a command...telling you it can't find that user ID. Aren't you providing the input list of users? Have you checked it for control/whitespace characters? There's obviously something wrong with the input data, or a difference between the users that work and don't.
Thanks for the reply. The users are all local users and they are available in the server. It works if I reset the password manually. The text file format is as follows
ab123
cd234
for me it looks very strange:
id reported user exists, chpasswd reported user does not exist.
did you try it without script (I mean the same user, same commands)?
you can also try to write a simple script:
with no space before the "-s". If you're copying and pasting, this seems very strange.
In any case, to me it looks like there might be something funny in the script with the "echo" statements (possibly a special character or something). The code:
Code:
echo $i:$i
echo "$i:$i" | chpasswd -c
looks like it should echo the same information, but in the output this differs:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.