Sponsored Content
Top Forums Shell Programming and Scripting Shell/Perl Script to edit dhcpd.conf Post 302097033 by sysgate on Tuesday 21st of November 2006 07:06:54 AM
Old 11-21-2006
This, of course, is just the logic, the implementation could be "done in more than one way" Smilie
 

10 More Discussions You Might Find Interesting

1. Linux

dhcpd.conf

I have intall a REdhat 9.0 as a server and Ive configure to act as a DHCP however Im having technical problems b/c the file /etc/dhcpd.conf does not exists. I went to the text edit and I created : subnet 192.192.168.100.0 netmask 255.255.255.0 { range 192.168.100.10 192.168.100.150;... (1 Reply)
Discussion started by: keliy1
1 Replies

2. UNIX for Dummies Questions & Answers

Cannot edit inetd.conf???

I'm trying to edit the inetd.conf but for some reason when I vi into it, it says "Read Only" even though I am root and the perms are 777?!? (2 Replies)
Discussion started by: shorty
2 Replies

3. Linux

dhcpd.conf - static route

Hi, I've setup DHCP Server on RH linux AS3 and everything works fine except static routes. They are not getting effected on client systems. My dhcpd.conf: +++++++++++ ddns-update-style interim; ddns-updates off; option domain-name-servers 192.168.116.122; option domain-name... (3 Replies)
Discussion started by: prvnrk
3 Replies

4. Shell Programming and Scripting

help on a perl script to edit file

Hi, sample file looks like this.. <hp> <name> <detail>adsg</detail> ... ... </name><ft>4264</ft> </hp> I need to edit the last but one line using perl script. I want the format to be .. <hp> <name> <detail>adsg</detail> ... ... </name> (9 Replies)
Discussion started by: meghana
9 Replies

5. Shell Programming and Scripting

shell script to edit a file

i have a file called number which contains data as 1 2 3 4 5 6 7 8 9 0 9 8 7 6 5 4 3 2 1 0 0 1 2 3 4 needed a shell script to print the output as 1 7 7 1 4 and (2 Replies)
Discussion started by: jacky29
2 Replies

6. UNIX for Dummies Questions & Answers

edit /etc/syslog.conf (Solaris 10)

Hi, Im editing the file /etc/syslog.conf for Solaris 10 server in production. I need to add "auth and authpriv.": someone set the same? Have been successful? I would appreciate any suggestions. Greetings. The unmodified arhive is: (0 Replies)
Discussion started by: musul
0 Replies

7. Shell Programming and Scripting

Help with Perl to change dhcpd.conf file

Hi all, I am too new for this stuff and i am lost in perl tutorials. I need help to change dhcp entries in .conf file with a perl script. The file entries are like below : host bertha-clp-0 { hardware ethernet AA:0A:A0:00:6c:40; fixed-address 10.10.10.72; option... (6 Replies)
Discussion started by: ekckabatop
6 Replies

8. Shell Programming and Scripting

Shell Script to check dhcp conf file

Hi, I have to prepare a script to check the dhcp conf file. The script has to check for a specific parameter called circuit ID. If the Circuit ID is unique it should show the output that it is unique and if it is duplicate it should show that the Circuit ID is duplicate. I have prepared the... (4 Replies)
Discussion started by: Crazy_Nix
4 Replies

9. Shell Programming and Scripting

Listing IPs from the dhcpd.conf

Hy everybody, Within a dhcpd.conf file, we got some fixed IP adresses from 192.168.0.1 - 192.168.0.254. Sample: #ddns-update-style interim; ddns-update-style none; ignore client-updates; deny client-updates; authoritative; #### By red for PXE Booting allow booting; allow bootp; ###... (17 Replies)
Discussion started by: hermouche
17 Replies

10. UNIX for Beginners Questions & Answers

Changes in dhcpd.conf do not make a difference in DHCP service behaviour

Hi Experts, Our DHCP server currently answers the DHCP Discover requests from ServerX. In our dhcpd.conf file there are parameters defined for ServerX. Now we introduced some additional Servers into the network and want them to get service from the same DHCP server. Similar configuration... (13 Replies)
Discussion started by: ekorgur
13 Replies
NodeFilter(3pm) 					User Contributed Perl Documentation					   NodeFilter(3pm)

NAME
XML::NodeFilter - Generic XML::NodeFilter Class SYNOPSIS
use XML::NodeFilter; my $filter = XML::NodeFilter->new(); $your_iterator->set_filter( $filter ); DESCRIPTION
"Filters are objects that know how to "filter out" nodes. If a NodeIterator or a TreeWalker is given a NodeFilter, it applies the filter before it returns the next node. If the filter says to accept the node, the traversal logic returns it; otherwise, traversal looks for the next node and pretends that the node was rejected was not there." This definition is given by the DOM Traversal and Range Specification. It explains pretty well, what this class is for: A XML::NodeFilter will recieve a node from a traversal object, such as XML::LibXML::Iterator is one and tells if the given node should be returned to the caller or not. Although I refere only to XML::LibXML here, XML::NodeFilter is implemented more open, so it can be used with other DOM implementations as well. The Spec And The Implementation The DOM Traversal and Range Specification just defines the contstants and accept_node() for a node filter. The XML::NodeFilter implementation also adds the what_to_show() function to the class definition, since I think that it is a filters job to decide which node- types should be shown and which not. Also XML::NodeFilter adds two constants which are not part of the specification. The first one is FILTER_DECLINED. It tells the traversal logic, that it should apply another filter in order to decide if the node should be visible or not. While the spec only defines the traversal logic to have either one or no filter applied, it showed that it leads to cleaner code if more filter could be used in conjunktion. If a traversal logic finds a single filter that returns FILTER_DECLINED, it should be handled as a synonym of FILTER_ACCEPT. While FILTER_ACCEPT is finite and would cause all other not to be executed, FILTER_DECLINED gives one more flexibility. The second extension of the specification is the SHOW_NONE symbol. It was added for operational completeness, so one can explicitly switch the node type filter off (means all node types are rejected). This will cause the two calls of what_to_show have a different result: $filter->what_to_show( undef ); # will set SHOW_ALL $filter->what_to_show( SHOW_NONE ); # will not set SHOW_ALL Infact SHOW_NONE is a NULL flag, that means it can be added to any list of flags without altering it. $filter->what_to_show( SHOW_ELEMENT | SHOW_TEXT | SHOW_NONE ); is therefore identical to $filter->what_to_show( SHOW_ELEMENT | SHOW_TEXT ); SHOW_NONE is espacially usefull to avoid numerically or even more ugly unintialized values while building such flag lists dynamically. How To write a Node Filter with XML::NodeFilter? Actually writing a node filter becomes very simple with XML::NodeFilter: Simply inherit your specialized node filter from XML::NodeFilter and implement your implement the function accept_node(). This name is more perlish than the name given by the specification. If your implementation needs to stay very close to the specification, you can alternativly implement acceptNode(). Implementing both functions makes no sense, since accept_node() should be prefered by the traversal logic. Because of this acceptNode() will only be called if no accept_node() implementation was given. Example: package My::NodeFilter; use XML::NodeFilter qw(:results); use vars qw(@ISA); @ISA = qw(XML::NodeFilter); use XML::LibXML::Common; sub accept_node { my $filter = shift; my $node = shift; unless ( $node->getNodeType == ELEMENT_NODE and defined $node->getNamespaceURI ) { # ignore node without a defined namespace return FILTER_REJECT; } return FILTER_DECLINED; } 1; This example shows a simple nodefilter that will reject any element without a namespace defined. Note that FILTER_DECLINED is returned if the node was not rejected. This allows a traversal logic to apply another filter on the nodes with a namespace defined. If your application needs to use different filters on the namespaced elements depending on the state where you want to traverse your DOM but you need allways to ignore elements without a namespace such a filter will enshure that you need not to add redundant code to your filter or even to choose a base class. How To make use of a XML::NodeFilter Filter? If you need to write some traversal code yourself, you should call the node filters accept_node() function to test if the logic should return the current node. A node is not returned if any filter retunrs FILTER_SKIP or FILTER_REJECT. In this case you need to reinvoke your traversal code. The following code snippet shows how you can make use of XML::NodeFilter in your traversal logic: use XML::NodeFilter qw(:results); #... sub traversal_logic { my $refnode = shift; my @filters = @_; my $node = undef; TRAVERSE: while(1) { my $state = FILTER_DECLINED; # your traversal logic # ... last TRAVERSE unless defined $node; FILTER: foreach my $filter ( @filters ) { $state = $filter->accept_node($node); last TRAVERSE if $state == FILTER_ACCEPT; last FILTER unless $state == FILTER_DECLINED; last TRAVERSE if $state == FILTER_DECLINED; } return $node; } As you see the traversal code will call only accept_node() on each filter. Still this will work fine with filters, that have acceptNode() implemented: XML::NodeFilter calls acceptNode() if the original accept_node() function is called. This ashures that filters that use function names conform to the specification will work as well. Note that XML::NodeFilter uses as default return value of accept_node() FILTER_ACCEPT rather than FILTER_DECLINED. This is done so you can write 100% specification conform traversal and filter logic. Functions new() As the constructor of this class it accepts some parameters in form of a hash. This parameter hash will be blessed into a hash reference. The only parameter used by the class itself is -show. This parameter may hold a bitmask of node filter flags as described below or a hash reference containing the same information. If -show is ommited SHOW_ALL is assumed as default. what_to_show() This function is added to the filter class, rather than assuming it is available directly from within a traversal logic. what_to_show() takes either a bitmask or a hash that holds the information what nodes should be filtered. If what_to_show() is called without any parameter, it simply returns the bitmaks in scalar context; if called in array context it returns a hash containing the corresponding information: If a bit is set in the bitmask the corresponding key has the value 1; otherwise it has the value 0. accept_node() This function is used to tell a calling traversal function if a given node should be returned to the caller or should be skipped. It has four possible return values: FILTER_DECLINED to indicate that the filter itself would accept if no other (less significant) filters rejects or skips it. NOTE FILTER_DECLINED is not defined by the spec. FILTER_ACCEPT to indicate that a node is accepted regardless what other filters may indicate. FILTER_SKIP to indicate a node is skipped, but its descendants should be still available. FILTER_REJECT to indicate a node and all its descendants should be skipped by the traversal logic. By default accept_node() returns FILTER_ACCEPT. acceptNode() Alternative function for accept_node(). This is only available for spec conformance. Any traversal logic should request accept_node(). Node filter implementations may choose either to implement accept_node() or acceptNode(). Implmenting both makes no sense at all! Constants o FILTER_DECLINED(0) Additional symbol to allow stacked node filters. o FILTER_ACCEPT(1) Defined by the specification o FILTER_SKIP(2) Defined by the specification o FILTER_REJECT(3) Defined by the specification o SHOW_ALL Defined by the specification o SHOW_ELEMENT Defined by the specification o SHOW_ATTRIBUTE Defined by the specification o SHOW_TEXT Defined by the specification o SHOW_CDATA_SECTION Defined by the specification o SHOW_ENTITY_REFERENCE Defined by the specification o SHOW_ENTITY Defined by the specification o SHOW_PROCESSING_INSTRUCTION Defined by the specification o SHOW_COMMENT Defined by the specification o SHOW_DOCUMENT Defined by the specification o SHOW_DOCUMENT_TYPE Defined by the specification o SHOW_DOCUMENT_FRAGMENT Defined by the specification o SHOW_NOTATION Defined by the specification o SHOW_NONE Additional symbol to indicate a NULL filter. This is for operational completeness. o @FLAGNAMES Contains the names of the FLAGS used by what_to_show(). The combining symbols SHOW_ALL and SHOW_NONE are not included by this list. o %FLAGMAPPING This hash mapps flagnames (as listed by @FLAGNAMES) to their predefined values. The combining symbols SHOW_ALL and SHOW_NONE are not included by this list. NOTE: @FLAGNAMES and %FALGMAPPING are not exported. To make use of them you have to use the fully quallified namespace as follows # gives the value of the SHOW_ELEMENT. my $flag = $XML::NodeFilter::FLAGMAPPING{SHOW_ELEMENT}; EXPORTS
XML::NodeFilter will not export any symbols at all. Instead it gives two tags: ':results' and ':flags'. :results This tag exports the FILTER_* constants. This is usefull to avoid hardcoded numerical values within the filter code or the traversal logic. These symbols are used by accept_node() and are required to indicate the state :flags Exports SHOW_* flags. Import these symbols if what_to_show() should be used conform to the specification rather than using named parameters. Alternativly you might import ':all' to get all symbols exported by both of the tags just described. AUTHOR
Christian Glahn, <christian.glahn@uibk.ac.at> SEE ALSO
perl, XML::LibXML::Iterator, XML::LibXML::NodeFilter W3C DOM Level 2 Traversal and Range Specification COPYRIGHT AND LICENSE
(c) 2002, Christian Glahn. All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2002-11-08 NodeFilter(3pm)
All times are GMT -4. The time now is 08:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy