From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Message-ID: <40B1CA26.1070204@ricom.ru> Date: Mon, 24 May 2004 14:10:46 +0400 From: Alexey Morsov Organization: Ricom-Trust User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7b) Gecko/20040421 X-Accept-Language: ru-ru, ru, ja MIME-Version: 1.0 To: community@altlinux.ru Subject: Re: [Comm] Ldap scripting: bash vs perl References: <40B1C951.3030204@rmts.donpac.ru> In-Reply-To: <40B1C951.3030204@rmts.donpac.ru> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: community@altlinux.ru X-Mailman-Version: 2.1.4 Precedence: list Reply-To: community@altlinux.ru List-Id: Mailing list for ALT Linux users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 May 2004 10:10:48 -0000 Archived-At: List-Archive: List-Post: Eugene Prokopiev wrote: > Здравствуйте! > > Есть 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 > > > Что я сделал не так? А что вас не устраивает? Вы же не ждете от большого Perl той же прыти как от куцего shell? > -- Всего наилучшего, Системный Администратор ЗАО "ИК "РИКОМ-ТРАСТ" Алексей Морсов http://www.ricom.ru http://www.fondmarket.ru