Sponsored Content
Full Discussion: dbm file in NIS
Operating Systems Solaris dbm file in NIS Post 302271939 by otheus on Monday 29th of December 2008 06:01:18 AM
Old 12-29-2008
NIS stores its information in DBM files. These are key-value databases. (Every key is unique and has one value). NIS does this so that the information is retained across process restarts. There are some programs to read from a DBM file. Usually, one can use perl to do more interesting things to the data:
Code:
#!/usr/bin/perl
dbmopen(%NISDAT,$ARGV[0],0444) || die "Cannot open $ARGV[0] : $!";
while (($key,$val) = each %NISDAT) {
   print $key, '=', $val,"\n";
}
dbmclose(%NISDAT);

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Solaris NIS+ and RedHat NIS+

Hello all, I'm not sure if this is the right forum, but I would like to know if Redhat running NIS ( not NIS +) would have conflict with Solaris running NIS+. Currently I am running NIS+ on Solaris but will be adding RedHat to the network. I seem to be unable to find and information regarding... (2 Replies)
Discussion started by: larry
2 Replies

2. IP Networking

differences nis nis+

Hello together. Is there someone who is able to explain me the differences between NIS and NIS+. thanks in advance joerg (2 Replies)
Discussion started by: joerg
2 Replies

3. UNIX for Dummies Questions & Answers

DBM View

Can someone please recommend a UNIX based utility (Not Web) to view a DBM file? Michael (1 Reply)
Discussion started by: schafferm
1 Replies

4. UNIX for Dummies Questions & Answers

NIS map mail.aliases specified, but NIS not running

Hi all, I just took over the admin role from someone and I wanna setup sendmail (just to send mail from the host) however, after I config all the resolv.conf, nssitch.conf, hosts file and when I try to send a mail out, after I punched ctl-D, it returned he following, "NIS map mail.aliases... (2 Replies)
Discussion started by: stancwong
2 Replies

5. UNIX for Advanced & Expert Users

SUSE 9 and 10 NIS clients with RedHat 8.0 NIS server not working

We have a RedHat 8.0 NIS master, with a RedHat 8.0 NIS Slave. We also have a small number of SUSE 9.1 and SUSE 10 machines here for evaluation. However, no matter what i do, the SUSE machines will not talk to the NIS Servers. If i broadcast for NIS Servers for the specified NIS domain, it... (1 Reply)
Discussion started by: fishsponge
1 Replies

6. Solaris

How to configure a NIS client bound to the NIS server in another subnet?

Hi, all. I have a Solaris client here needs to bind to NIS server in another subnet. Following is the configuration i made on the client, 1) edit /etc/inet/hosts to add an entry of the NIS server -- nserver01 2) execute `domainname` to set local NIS domain to the domain of the NIS server.... (1 Reply)
Discussion started by: sn_wukong
1 Replies

7. Solaris

NIS password file update issue

Hi Our nis server running on Sun solaris 8 operating system. I have added a new user in the nis passwd file & when I am trying to update the file from nis server by using following command: # cd /var/yp # make updated passwd It updates the passwd file but does not come back to command... (3 Replies)
Discussion started by: dolphin
3 Replies

8. UNIX for Dummies Questions & Answers

DBM database conversion?

I have a DBM database back up file I'd like to convert to mySQL or even to a .CSV, but....... How can I do it? The big problem is I have no idea about scripts, how to install them etc. so these methods are basically useless to me. I guess is there a data base migration software for dummies? (1 Reply)
Discussion started by: ash33
1 Replies

9. UNIX for Dummies Questions & Answers

Nis

Hello i have some account already defined on NIS server. I would like to use this account on my machine. What do i have to do ? Only create the home directory then use the account ?? If the user defined is using the korn shell, and i want to use bash, how can i change it ?? (2 Replies)
Discussion started by: dolphin06
2 Replies

10. Shell Programming and Scripting

Validating that the NIS and NIS+ services are disabled

I'm creating a scrip for auditing our AIX box's to ensure that they are built according to our system standards. I'm not sure on the logic for checking to see if the NIS and NIS+ services are disabled. any idea's? (2 Replies)
Discussion started by: sport
2 Replies
PERLDBMFILTER(1)					 Perl Programmers Reference Guide					  PERLDBMFILTER(1)

NAME
perldbmfilter - Perl DBM Filters SYNOPSIS
$db = tie %hash, 'DBM', ... $old_filter = $db->filter_store_key ( sub { ... } ); $old_filter = $db->filter_store_value( sub { ... } ); $old_filter = $db->filter_fetch_key ( sub { ... } ); $old_filter = $db->filter_fetch_value( sub { ... } ); DESCRIPTION
The four "filter_*" methods shown above are available in all the DBM modules that ship with Perl, namely DB_File, GDBM_File, NDBM_File, ODBM_File and SDBM_File. Each of the methods work identically, and are used to install (or uninstall) a single DBM Filter. The only difference between them is the place that the filter is installed. To summarise: filter_store_key If a filter has been installed with this method, it will be invoked every time you write a key to a DBM database. filter_store_value If a filter has been installed with this method, it will be invoked every time you write a value to a DBM database. filter_fetch_key If a filter has been installed with this method, it will be invoked every time you read a key from a DBM database. filter_fetch_value If a filter has been installed with this method, it will be invoked every time you read a value from a DBM database. You can use any combination of the methods from none to all four. All filter methods return the existing filter, if present, or "undef" in not. To delete a filter pass "undef" to it. The Filter When each filter is called by Perl, a local copy of $_ will contain the key or value to be filtered. Filtering is achieved by modifying the contents of $_. The return code from the filter is ignored. An Example -- the NULL termination problem. DBM Filters are useful for a class of problems where you always want to make the same transformation to all keys, all values or both. For example, consider the following scenario. You have a DBM database that you need to share with a third-party C application. The C appli- cation assumes that all keys and values are NULL terminated. Unfortunately when Perl writes to DBM databases it doesn't use NULL termina- tion, so your Perl application will have to manage NULL termination itself. When you write to the database you will have to use something like this: $hash{"$key"} = "$value"; Similarly the NULL needs to be taken into account when you are considering the length of existing keys/values. It would be much better if you could ignore the NULL terminations issue in the main application code and have a mechanism that automati- cally added the terminating NULL to all keys and values whenever you write to the database and have them removed when you read from the database. As I'm sure you have already guessed, this is a problem that DBM Filters can fix very easily. use strict; use warnings; use SDBM_File; use Fcntl; my %hash; my $filename = "filt"; unlink $filename; my $db = tie(%hash, 'SDBM_File', $filename, O_RDWR|O_CREAT, 0640) or die "Cannot open $filename: $! "; # Install DBM Filters $db->filter_fetch_key ( sub { s/$// } ); $db->filter_store_key ( sub { $_ .= "" } ); $db->filter_fetch_value( sub { no warnings 'uninitialized'; s/$// } ); $db->filter_store_value( sub { $_ .= "" } ); $hash{"abc"} = "def"; my $a = $hash{"ABC"}; # ... undef $db; untie %hash; The code above uses SDBM_File, but it will work with any of the DBM modules. Hopefully the contents of each of the filters should be self-explanatory. Both "fetch" filters remove the terminating NULL, and both "store" filters add a terminating NULL. Another Example -- Key is a C int. Here is another real-life example. By default, whenever Perl writes to a DBM database it always writes the key and value as strings. So when you use this: $hash{12345} = "something"; the key 12345 will get stored in the DBM database as the 5 byte string "12345". If you actually want the key to be stored in the DBM data- base as a C int, you will have to use "pack" when writing, and "unpack" when reading. Here is a DBM Filter that does it: use strict; use warnings; use DB_File; my %hash; my $filename = "filt"; unlink $filename; my $db = tie %hash, 'DB_File', $filename, O_CREAT|O_RDWR, 0666, $DB_HASH or die "Cannot open $filename: $! "; $db->filter_fetch_key ( sub { $_ = unpack("i", $_) } ); $db->filter_store_key ( sub { $_ = pack ("i", $_) } ); $hash{123} = "def"; # ... undef $db; untie %hash; The code above uses DB_File, but again it will work with any of the DBM modules. This time only two filters have been used -- we only need to manipulate the contents of the key, so it wasn't necessary to install any value filters. SEE ALSO
DB_File, GDBM_File, NDBM_File, ODBM_File and SDBM_File. AUTHOR
Paul Marquess perl v5.8.9 2007-11-17 PERLDBMFILTER(1)
All times are GMT -4. The time now is 01:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy