Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Help asked for creating a file with usernames

by johngg (Abbot)
on Feb 09, 2013 at 14:49 UTC ( #1017966=note: print w/ replies, xml ) Need Help??


in reply to Help asked for creating a file with usernames

A more long-winded approach would be to read and print the file line by line and, if we have found an address line, print the two new preceding lines and add the /32 at the end.

$ perl -Mstrict -Mwarnings -e ' > open my $usersFH, q{<}, \ <<EOD or die open qq{open: < HEREDOC: $!\n +}; > dn: uid=donald,nameSpace=mydomain.com,ou=users,o=sp > radiusFramedAddress: 192.168.0.2 > > dn: uid=mario,nameSpace=mydomain.com,ou=users,o=sp > radiusFramedAddress: 192.168.0.7 > > dn: uid=thijs,nameSpace=mydomain.com,ou=users,o=sp > radiusFramedAddress: 192.168.11.15 > EOD > > while ( <$usersFH> ) > { > if ( m{^radiusFramedAddress:} ) > { > print > qq{changeType: modify\nreplace: radiusFramedAddress\n}; > s{$}{/32}; > } > print; > }' dn: uid=donald,nameSpace=mydomain.com,ou=users,o=sp changeType: modify replace: radiusFramedAddress radiusFramedAddress: 192.168.0.2/32 dn: uid=mario,nameSpace=mydomain.com,ou=users,o=sp changeType: modify replace: radiusFramedAddress radiusFramedAddress: 192.168.0.7/32 dn: uid=thijs,nameSpace=mydomain.com,ou=users,o=sp changeType: modify replace: radiusFramedAddress radiusFramedAddress: 192.168.11.15/32 $

I hope this is helpful.

Cheers,

JohnGG


Comment on Re: Help asked for creating a file with usernames
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017966]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-07-03 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (51 votes), past polls