ALT Linux Community general discussions
 help / color / mirror / Atom feed
* [Comm] Ldap scripting: bash vs perl
@ 2004-05-24 10:07 Eugene Prokopiev
  2004-05-24 10:10 ` Alexey Morsov
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Eugene Prokopiev @ 2004-05-24 10:07 UTC (permalink / raw)
  To: community

Здравствуйте!

Есть 2 тупых скрипта:

# cat make_ldap_filter.pl

#!/usr/bin/perl
use Net::LDAP;
$ldap = Net::LDAP->new('localhost') or die "$@";
$ldap->bind;
$mesg = $ldap->search(
     base => "dc=myserver, dc=myprovider, dc=ru",
     filter => sprintf("(&(objectClass=internetAccess) (%s=TRUE))", @ARGV)
);
$mesg->code && die $mesg->error;
foreach $entry ($mesg->all_entries) {
     foreach my $value ($entry->get_value('dhcpStatements')) {
         if ($value =~ /fixed-address /) {
             print "$'\n";
         }
     }
}
$ldap->unbind;

# cat make_ldap_filter.sh

#!/bin/bash
ldapsearch -LLL "(&(objectClass=internetAccess) ("$1"=TRUE))" | grep 
fixed-address | awk '{print $3}'

А вот время их выполнения:

# time ./make_ldap_filter.pl allowNat
192.168.101.15
...
192.168.101.95
2.42user 0.18system 0:03.18elapsed 81%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (436major+833minor)pagefaults 0swaps

# time ./make_ldap_filter.sh allowNat
192.168.101.15
...
192.168.101.95
0.09user 0.04system 0:00.36elapsed 35%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (834major+202minor)pagefaults 0swaps


Что я сделал не так?

-- 
С уважением, Прокопьев Евгений



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2004-05-26  9:08 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-24 10:07 [Comm] Ldap scripting: bash vs perl Eugene Prokopiev
2004-05-24 10:10 ` Alexey Morsov
2004-05-24 10:36   ` Eugene Prokopiev
2004-05-24 11:06     ` Mike Lykov
2004-05-24 11:10       ` Eugene Prokopiev
2004-05-24 10:22 ` Klimchev Konstantin
2004-05-24 10:29   ` Eugene Prokopiev
2004-05-24 10:45     ` Alexey Morsov
2004-05-24 10:59       ` Eugene Prokopiev
2004-05-24 11:22     ` Klimchev Konstantin
2004-05-24 11:32       ` Eugene Prokopiev
2004-05-25  7:43 ` Klimchev Konstantin
2004-05-25  8:21   ` Mike Lykov
2004-05-25  8:31     ` Klimchev Konstantin
2004-05-25  8:51       ` Mike Lykov
2004-05-25  8:58         ` Klimchev Konstantin
2004-05-25 10:43 ` [Comm] " Alexey Tourbin
2004-05-26  6:06 ` [Comm] " Eugene Prokopiev
2004-05-26  6:14   ` Klimchev Konstantin
2004-05-26  8:04     ` Eugene Prokopiev
2004-05-26  8:20       ` Klimchev Konstantin
2004-05-26  9:08         ` Eugene Prokopiev

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git