For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2008 > NIS map lookup









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author NIS map lookup
Vahid Moghaddasi

2008-01-23, 7:06 pm

Hi all,
I am trying to modify a korn shell script to Perl to get rid of sed,
awk, etc... For most part I am done but I cant seem to be able to find
an included or CPAN module to lookup NIS maps, such as password,
group.. and also "ypwhich -m"
I will need to get the name of the maps and dump each map one by one.
This is the Korn shell equivalent of what I need in Perl:
automaster=`ypcat auto.master | grep auto | awk '{print $1}'`
maps=`ypwhich -m awk '{print $1}'`

for map in $maps
do
ypcat $map > $tmp/nis.$map
done

Thanks you all very much.
John W. Krahn

2008-01-23, 7:06 pm

Vahid Moghaddasi wrote:
> Hi all,


Hello,

> I am trying to modify a korn shell script to Perl to get rid of sed,
> awk, etc... For most part I am done but I cant seem to be able to find
> an included or CPAN module to lookup NIS maps, such as password,
> group.. and also "ypwhich -m"
> I will need to get the name of the maps and dump each map one by one.
> This is the Korn shell equivalent of what I need in Perl:
> automaster=`ypcat auto.master | grep auto | awk '{print $1}'`
> maps=`ypwhich -m awk '{print $1}'`
>
> for map in $maps
> do
> ypcat $map > $tmp/nis.$map
> done


http://search.cpan.org/~esm/Net-NIS-0.43/NIS.pod

<QUOTE>

As a special case, the magic map __YPMASTER can be used as an equivalent
to 'ypwhich -m':

tie %ypmaster, 'Net::NIS', '__YPMASTER' or die ...;
printf "ypmaster(passwd) = %s\n", $ypmaster{'passwd.byname'};

print $_, "\n" for sort keys %ypmaster; # Only works on Linux!

Note that keys() only works on Linux, because Linux includes a helpful
yp_maplist() function. On Linux, you can get a list of existing YP maps.
On other OSes, you can't -- but given the name of an existing map,
$ypmaster{$map} will work as expected.

</QUOTE>



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
Tom Phoenix

2008-01-23, 7:06 pm

On Jan 23, 2008 11:46 AM, Vahid Moghaddasi <vahid.moghaddasi@gmail.com> wrote:

[color=darkred]
> I had attempted to install this module on Solaris but gave me so many
> errors during compilation that I gave up. I guess it is written for
> Linux only. I guess the problem is that somewhere in the installation
> it is hard coded to use cc compiler instead of gcc.


Where did you get that idea?

I see several success reports from Solaris machines on this page:

http://cpantesters.perl.org/show/Ne...ml#Net-NIS-0.43

> I get this error when use the module:
> Can't locate auto/Net/NIS/TIEHASH.al in @INC ....


How did you try to build, test, and install the module?

--Tom Phoenix
Stonehenge Perl Training
Vahid Moghaddasi

2008-01-23, 7:06 pm

On Jan 23, 2008 11:40 AM, John W. Krahn <krahnj@telus.net> wrote:
>
> http://search.cpan.org/~esm/Net-NIS-0.43/NIS.pod
>
> <QUOTE>
>
> As a special case, the magic map __YPMASTER can be used as an equivalent

I had attempted to install this module on Solaris but gave me so many
errors during compilation that I gave up. I guess it is written for
Linux only. I guess the problem is that somewhere in the installation
it is hard coded to use cc compiler instead of gcc. I looked in
Makefile.PL but there is nothing to change there.
I get this error when use the module:
Can't locate auto/Net/NIS/TIEHASH.al in @INC ....

Thanks..
Vahid Moghaddasi

2008-01-23, 7:06 pm

On Jan 23, 2008 2:56 PM, Tom Phoenix <tom@stonehenge.com> wrote:

>
> Where did you get that idea?
>


The Makefile generated by perl Makefile.PL has compiler options for cc
that wont work for gcc.

> I see several success reports from Solaris machines on this page:
>
> http://cpantesters.perl.org/show/Ne...ml#Net-NIS-0.43
>

The success stories also compiled with 'cc' but they used gcc options
in the makefile.
I was also able to compile with gcc options and compile and install the module.

>
> How did you try to build, test, and install the module?
>

perl Makefile.PL
vi Makefile and changed the compiler options
make
vi t/tabletest to pint it to a correct perl in /bin/perl
t/tabletest
# I see over 8000 lines of my hosts table and:
---------------------------------------------------------------------------
no data returned
status: 4
---------------------------------------------------------------------------
make install

Am I supposed to do anything else?
I am using Solaris 10 U4.
Thanks,
Tom Phoenix

2008-01-23, 7:06 pm

On Jan 23, 2008 1:17 PM, Vahid Moghaddasi <vahid.moghaddasi@gmail.com> wrote:
> On Jan 23, 2008 2:56 PM, Tom Phoenix <tom@stonehenge.com> wrote:
>
>
> The Makefile generated by perl Makefile.PL has compiler options for cc
> that wont work for gcc.


That's probably because you generally need the same compiler options
(and the same compiler) when building extensions to your perl binary
as were used to build the binary itself.

> perl Makefile.PL
> vi Makefile and changed the compiler options


If you couldn't have more easily passed those options to 'perl
Makefile.PL' on the command line, something is wrong.

> make
> vi t/tabletest to pint it to a correct perl in /bin/perl
> t/tabletest


You should be running the tests with 'make test'.

> # I see over 8000 lines of my hosts table and:
> ---------------------------------------------------------------------------
> no data returned
> status: 4
> ---------------------------------------------------------------------------


That does not sound like a successful test. :-(

Running 'perl Makefile.PL' gives you a Makefile that's customized for
the compiler and options that were used for your perl binary. If the
resulting Makefile is for a C compiler you don't have, you probably
need to go back a step and compile and install perl with a C compiler
that you do have.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training
Vahid Moghaddasi

2008-01-23, 7:06 pm

On Jan 23, 2008 4:47 PM, Tom Phoenix <tom@stonehenge.com> wrote:
>
> That's probably because you generally need the same compiler options
> (and the same compiler) when building extensions to your perl binary
> as were used to build the binary itself.
>


Most likely you are correct, the perl was already installed on Solaris.

>
> That does not sound like a successful test. :-(
>
>


I managed to get it to work with difficulty...but I have to add
Net::NIS:: in front of every function I call which, is OK with me.
e.g. Net::NIS::yp_get_default_domain()

Thank you very much for your help.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com