- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script File for /etc/password
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2004 09:23 AM
тАО02-17-2004 09:23 AM
I am new at scripting and need help??
I need to modify /etc/password file and compare the username to the username in a flat file if it finds it then replace the comments field in /etc/pasword and populated from a flat file with this string Ex. "C-137h 897 Abu Sassi (HP)".
Thanks for your help in Advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2004 09:27 AM
тАО02-17-2004 09:27 AM
Re: Script File for /etc/password
Test it out first on a copy though.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2004 09:40 AM
тАО02-17-2004 09:40 AM
Re: Script File for /etc/password
I am actually looking for a script to modify the field in /etc/password file by parsing a flat file.
Thanks
Abu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2004 11:04 AM
тАО02-17-2004 11:04 AM
SolutionYou can wait to see other responses. The caveat with chfn function is that it will put blanks with commas for the missing fields. Make sure to *take a backup* of your /etc/passwd file. Also make sure you are only the one working on the system as an administrator during this time. Create a file called 'infile' (changeable) in the following format
user1: C-137h 897 Abu Sassi (HP)
user2: Someone else
user3: bla bla bla
Make sure you don't have a ":" anywhere other than as the seperator itself.
//start of script
#!/usr/bin/ksh
PASSWD=/etc/passwd
MYFILE=infile
while read LINE
do
USER=$(echo $LINE|awk '{FS=":";print $1}')
GECOS=$(echo $LINE|awk '{FS=":";print $2}')
printf "%-20s" "Doing for $USER"
grep -q "^${USER}:" $PASSWD
if [ $? = 0 ]
then
chfn $USER << EOF > /dev/null 2>&1
none
none
none
$GECOS
EOF
printf "- Done\n"
else
printf "- N/A\n"
fi
done < $MYFILE
// end of script
Once the script is run, you can replace ":,,," by editing the passwd file with the command 'vipw' and %s:/:,,,/:/g macro.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-18-2004 03:43 AM
тАО02-18-2004 03:43 AM
Re: Script File for /etc/password
I am going to try it and give you my feed back. Your script looks very good. Thanks for all who repond to my post.
Abu