Sponsored Content
Top Forums Shell Programming and Scripting Reading from one file and updating other file with constant entries Post 302498858 by Samingla on Tuesday 22nd of February 2011 04:33:25 PM
Old 02-22-2011
Reading from one file and updating other file with constant entries

Hi All,

Thaks for the help in my last thread. I have one more question. I have two files with ldap entries in it. One file contains all the user LDAP parameter entries (26 MB) and other file contains only the user id's that have to be inactivated. Unix script has to read from the file that has user id information that has to be inactivated and update the main file with constant text. It has to update only those entries that are in the file that has the list of users to inactivate. Below is an example with input files and utput files that I need.

File 1
Code:
A:
uid: 1111
C:
D:
E:
 
A:
uid: 2222
C:
D:
E:
 
A:
uid: 3333
C:
D:
E:
 
A:
uid: 4444
C:
D:
E:

File 2
Code:
uid: 1111
uid: 3333
uid: 6666
.....

Output File

Code:
A:
uid: 1111
C:
D:
E:
nsrole: cn=nsdisabledrole,dc=wwww,dc=cccc,dc=com
nsrole: cn=nsmanageddisabledrole,dc=wwww,dc=cccc,dc=com
nsaccountlock: true
 
A:
uid: 2222
C:
D:
E:
 
A:
uid: 3333
C:
D:
E:
nsrole: cn=nsdisabledrole,dc=wwww,dc=cccc,dc=com
nsrole: cn=nsmanageddisabledrole,dc=wwww,dc=cccc,dc=com
nsaccountlock: true
 
A:
uid: 4444
C:
D:
E:


Thanks in advance
Samingla
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 02-22-2011 at 05:42 PM.. Reason: code tags, please!
 

10 More Discussions You Might Find Interesting

1. Programming

File descriptor constant

I have a requirement to close all the file descriptors from 3 to 1024 for a particular application. Right now, this is how I do it .. for ( int i = 3 ; i <= 1024; ++i ) close(i); The change I am looking at is, I want to do away with the number 1024 and replace it with a constant which... (4 Replies)
Discussion started by: vino
4 Replies

2. Shell Programming and Scripting

awk updating one file with another, comparing, updating

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

3. UNIX for Dummies Questions & Answers

Updating a field in a File without creating temp file's

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

4. Shell Programming and Scripting

how I can add a constant to a field without changing the file format

Hi, I need to edit a file Protein Data Bank (pdb) and then open that file with the program VMD but when I edit the file with awk, it changes pdb format and the VMD program can not read it. I need to subtract 34 to field 6 ($ 6). this is a pdb file : ATOM 918 N GLY B 103 -11.855 8.675... (8 Replies)
Discussion started by: bio_
8 Replies

5. Shell Programming and Scripting

Help with reading file with values and updating another file

Hi I need some help with a task, i am an absolute newbie to any form of shell scripting and request guidance. Task: 1. Read a config file in form of name value pair ex host=www.test.com port=8080 binding="dynamic" or "other" or "something else" key1=value1 key2=value2 key3=value4... (4 Replies)
Discussion started by: mk7074
4 Replies

6. Shell Programming and Scripting

reading and updating property file

I have to do a read operation for a field in property file, which looks like follows: 123|xyz|datetime|count '|' is delimiter. Finally I managed to read the contents of property file using statement like cut -d"|" -f1 $PROPERTIES_FILE | tr '\n' ' ' <-- Reading first column But now I... (2 Replies)
Discussion started by: rakeshranjanscs
2 Replies

7. Programming

[Makefile]File + constant problem

Hi guys, I am writing a Makefile with some strange features. What I have is: list of files *.efi list of guids (guid is just a number) one *.efi file is supposed to be used with one guid, so efi file and guid is a pair. What I need is: list of files *.fv How to make *.fv file... (1 Reply)
Discussion started by: Chrisdot
1 Replies

8. Shell Programming and Scripting

awk for splitting file in constant chunks

Hi gurus, I wanted to split main file in 20 files with 2500 lines in each file. My main file conatins total 2500*20 lines. Following awk I made, but it is breaking with error. awk '{ for (i = 1; i <= 20; i++) { starts=2500*$i-1; ends=2500*$i; NR>=starts && NR<=ends {f=My$i".txt"; print >> f;... (10 Replies)
Discussion started by: mukesh.lalwani
10 Replies

9. Shell Programming and Scripting

Need to insert text(constant) at the beginning of file

I am very new to scripting and I know this request is simple but I am having no luck with it. I have a file a.dat with the following data in it. aa bb cc dd I need to run a script that will take each line of a.dat and put dsjc/ubin/ in front of each record, so the output looks like ... (2 Replies)
Discussion started by: jclanc8
2 Replies

10. Shell Programming and Scripting

Howto add a constant column to the text file

Hi, I am converting a .DBF file to pipe delimited file my requirement is like lets say my .DBF is residing in path /a/b/c/d/f/abc.DBF I need my .txt file as having a column with source _cd =f sample data in .DBF in folder "f" c1 c2 c3 1 2 3 in txt file it should be... (4 Replies)
Discussion started by: angel12345
4 Replies
gsscred(1M)						  System Administration Commands					       gsscred(1M)

NAME
gsscred - add, remove and list gsscred table entries SYNOPSIS
gsscred [ -n user [-o oid] [-u uid]] [-c comment] -m mech -a gsscred [ -n user [-o oid]] [-u uid] [-m mech] -r gsscred [ -n user [-o oid]] [-u uid] [-m mech] -l DESCRIPTION
The gsscred utility is used to create and maintain a mapping between a security principal name and a local UNIX uid. The format of the user name is assumed to be GSS_C_NT_USER_NAME. You can use the -o option to specify the object identifier of the name type. The OID must be specified in dot-separated notation, for example: 1.2.3.45464.3.1 The gsscred table is used on server machines to lookup the uid of incoming clients connected using RPCSEC_GSS. When adding users, if no user name is specified, an entry is created in the table for each user from the passwd table. If no comment is specified, the gsscred utility inserts a comment that specifies the user name as an ASCII string and the GSS-APIsecurity mechanism that applies to it. The security mechanism will be in string representation as defined in the /etc/gss/mech file. The parameters are interpreted the same way by the gsscred utility to delete users as they are to create users. At least one of the follow- ing options must be specified: -n, -u, or -m. If no security mechanism is specified, then all entries will be deleted for the user identi- fied by either the uid or user name. If only the security mechanism is specified, then all user entries for that security mechanism will be deleted. Again, the parameters are interpreted the same way by the gsscred utility to search for users as they are to create users. If no options are specified, then the entire table is returned. If the user name or uid is specified, then all entries for that user are returned. If a security mechanism is specified, then all user entries for that security mechanism are returned. OPTIONS
-a Add a table entry. -c comment Insert comment about this table entry. -l Search table for entry. -m mech Specify the mechanism for which this name is to be translated. -n user Specify the optional principal name. -o oid Specify the OID indicating the name type of the user. -r Remove the entry from the table. -u uid Specify the uid for the user if the user is not local. EXAMPLES
Example 1: Creating a gsscred Table for the Kerberos v5 Security Mechanism The following shows how to create a gsscred table for the kerberos v5 security mechanism. gsscred obtains user names and uid's from the passwd table to populate the table. example% gsscred -m kerberos_v5 -a Example 2: Adding an Entry for root/host1 for the Kerberos v5 Security Mechanism The following shows how to add an entry for root/host1 with a specified uid of 0 for the kerberos v5 security mechanism. example% gsscred -m kerberos_v5 -n root/host1 -u 0 -a Example 3: Listing All User Mappings for the Kerberos v5 Security Mechanism The following lists all user mappings for the kerberos v5 security mechanism. example% gsscred -m kerberos_v5 -l Example 4: Listing All Mappings for All Security Mechanism for a Specified User The following lists all mappings for all security mechanisms for the user bsimpson. example% gsscred -n bsimpson -l EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgss | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
gssd(1m), See gsscred.conf(4), attributes(5) NOTES
Some GSS mechanisms, such as kerberos_v5, provide their own authenticated-name-to-local-name (uid) mapping and thus do not usually have to be mapped using gsscred. See gsscred.conf(4) for more information. SunOS 5.10 11 Feb 2004 gsscred(1M)
All times are GMT -4. The time now is 07:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy