1753888 Members
7617 Online
108809 Solutions
New Discussion

Script-Nis Help.

 
joe_91
Super Advisor

Script-Nis Help.

Hi Gurus:

I have a script requirement which would have to run on any given machine, it should be able to find which is the Master NIS Server and which would be the slaves. In our current production we have 1 Master and 3 Slaves. In our Development/Testing we have 1 Master
and 1 Slave. The script should print out a statement

The Master server is ---------
The Slave is/are ....
The following command would give the required info..
ypcat -k ypservers (would print all the servers)
ypwhich -m ypservers (would print out the master).
Can someone help here please.

Thanks
Joe.
1 REPLY 1
Patrick Wallek
Honored Contributor

Re: Script-Nis Help.

I don't have a machine to test on, but something like this should work (note that all ` are the backwards quotes (back ticks)):

#!/sbin/sh

NISMASTER=`ypwhich -m ypservers`
NISSLAVE=`ypcat -k ypservers | grep -v $NISMASTER`

echo "The Master server is: $NISMASTER"

echo "The slave server(s) is/are: $NISSLAVE"