01-14-2009
Howzit Otheus,
I updated the script and I'm still getting syntax errors please have a look at the out put below: My prayers are not getting answered!!!!!!!!!!
#!/bin/bash
FILE1=/tmp/update.txt
FILE2=/etc/passwd
cp $FILE2 /etc/passwd.$$.orig
TEST=echo
for i in `awk -F: '$1 == "'"$HOSTNAME"'" && $2 == '"${i}"' { print $2 }' $FILE1`
do
if awk -F: '$1 == "'"${i}"'" { exit(0); } END { exit(1);}' $FILE2
then
FIELD1=`awk -F: '$2 == "'"${i}"'" { print $3 }' $FILE1`
$TEST usermod -c "${FIELD1}" $i
fi
done
~
~
[root@server1 script]# ./scriptlinuxcom.txt
awk: $1 == "server1.localdomain" && $2 == { print $2 }
awk: ^ syntax error
[root@server1 script]#
Last edited by otheus; 01-15-2009 at 05:50 AM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello, was looking for some help on extracting a field from the passwd file.
So far I have made a copy of the passwd file and changed my rights so I can edit it. Every user's password is coded as an :x:, and my goal was to change that x to a blank, and then try to extract any user with that field... (2 Replies)
Discussion started by: xBuRnTx
2 Replies
2. Programming
Hi
can anyone help me regarding the meaning of the following lint messages.
what is the use of having such lint comments in the c program.
/*lint -esym(534,cputs,fgets,cprintf) */
/*lint -efile(766,pragmas.h) */
Thanks a lot in advance. (5 Replies)
Discussion started by: axes
5 Replies
3. Shell Programming and Scripting
Hello,
I read and search through this wonderful forum and tried different approaches but it seems I lack some knowledge and neurones ^^
Here is what I'm trying to achieve :
file1:
test filea 3495;
test fileb 4578;
test filec 7689;
test filey 9978;
test filez 12300;
file2:
test filea... (11 Replies)
Discussion started by: mecano
11 Replies
4. Shell Programming and Scripting
Hi there,
I have more that 300 servers that I need to updated the comments field on /etc/passwd for users that have a blank comments fields. The users have accounts on different servers. I have created a list of these users on a text file called update_passwd.txt.
I need a script that will... (6 Replies)
Discussion started by: Linux Duke
6 Replies
5. UNIX for Dummies Questions & Answers
Hi Experts,
I have a requirement where i need to update the below items in file,
1. END TIME
2. PREV_STATUS
For the first time the PREV_status and end time of all job the job will be sysdate & NULL reply as below,
Session_name,Load Type,Frequency,Seesion End time,Prev_Status... (2 Replies)
Discussion started by: prabhutkl
2 Replies
6. Shell Programming and Scripting
I must write a script to change all C++ like comments:
// this is a comment
to this one
/* this is a comment */
How to do it by sed? With file:
#include <cstdio>
using namespace std; //one
// two
int main() {
printf("Example"); // three
}//four
the result should be: (2 Replies)
Discussion started by: black_hawk
2 Replies
7. Solaris
Hi Folks,
I have Solaris 10, latest release.
We have passwd aging set in /etc/defalut/passwd.
I have an account that passwd should never expire. Acheived by emptying associated users shadow file entries for passwd aging.
When I reset the users passwd using passwd command, it re enables... (3 Replies)
Discussion started by: BG_JrAdmin
3 Replies
8. UNIX for Dummies Questions & Answers
Hello i am back :D,
i have a prolem. I want to Delete the IPs which are in Comments.
Input
192.168.0.1
192.168.0.2
#192.168.0.3
#192.168.0.4 - when TAB or Space, delete too.
/*192.168.0.5
192.168.0.6
192.168.0.7*\
Output
192.168.0.1
192.168.0.2
My solution is sed -e... (7 Replies)
Discussion started by: eightball
7 Replies
9. AIX
Does anyone know when AIX started using /etc/security/passwd instead of /etc/passwd to store encrypted passwords? (1 Reply)
Discussion started by: Anne Neville
1 Replies
10. Solaris
Hi,
I have a Solaris 10 box where password aging is not functioning properly. Using the passwd command with the -l or -u options causes the lastchg field in the /etc/shadow file to be modified. Therefore, if a user's password is set to expire in 90 days and they are 1 day away, all they have... (4 Replies)
Discussion started by: cschar
4 Replies
GROUP(5) BSD File Formats Manual GROUP(5)
NAME
group -- format of the group permissions file
DESCRIPTION
The file </etc/group> consists of newline separated ASCII records, one per group, containing four colon ':' separated fields. These fields
are as follows:
group Name of the group.
passwd Group's encrypted password.
gid The group's decimal ID.
member Group members.
The group field is the group name used for granting file access to users who are members of the group. The gid field is the number associ-
ated with the group name. They should both be unique across the system (and often across a group of systems) since they control file access.
The passwd field is an optional encrypted password. This field is rarely used and an asterisk is normally placed in it rather than leaving
it blank. The member field contains the names of users granted the privileges of group. The member names are separated by commas without
spaces or newlines. A user is automatically in a group if that group was specified in their /etc/passwd entry and does not need to be added
to that group in the /etc/group file.
INTERACTION WITH DIRECTORY SERVICES
Processes generally find group records using one of the getgrent(3) family of functions. On Mac OS X, these functions interact with the
DirectoryService(8) daemon, which reads the /etc/group file as well as searching other directory information services to determine groups and
group membership.
FILES
/etc/group
SEE ALSO
passwd(1), setgroups(2), crypt(3), getgrent(3), initgroups(3), passwd(5), DirectoryService(8)
BUGS
The passwd(1) command does not change the group passwords.
HISTORY
A group file format appeared in Version 6 AT&T UNIX.
Mac OS X July 18, 1995 Mac OS X