Useful OneLiners
Posted on maart 21, 2008
Filed Under Perl One-Liners | Leave a Comment
# add first and penultimate columns
perl -lane 'print $F[0] + $F[-2]'
# just lines 15 to 17
perl -ne 'print if 15 .. 17' *.pod
# in-place edit of *.c files changing all foo to bar
perl -p -i.bak -e 's/\bfoo\b/bar/g' *.c
# command-line that prints the first 50 lines (cheaply)
perl -pe 'exit if $. > 50' f1 f2 f3 ...
Perl “One-Liners”
Posted on maart 21, 2008
Filed Under Perl One-Liners | Leave a Comment
Perl “One Liners” are -surprise surprise- little perl programs written on one line.
Here are a few simple examples :
Guess what this one does
$ perl -e 'print "Hello";' -e 'print " World\n"'
DOS to Unix text convert
$ perl -i -pe 's/\r//g' file
Unix to DOS text convert
$ perl -i -pe 's/\n/\r\n/' file
‘Fun’ with columns:
$ echo a b c | perl -lane 'print $F[1]'
b
$ echo a b c | perl -lane 'print "@F[0..1]"'
a b
$ echo a b c | perl -lane 'print "@F[-2,-1]"'
b c
More one-liners will follow…
Managing IP networks for free
Posted on januari 4, 2008
Filed Under OpenSource, Network Monitoring | Leave a Comment
Here’s a great tutorial on how you could manage your ip network for free! All you need is a Linux box (surprise surprise) and of course an ip network.
The tutorial discusses some popular tools and scripts to perform these tasks :
- Configuration change measurement: storing the configuration history of your network in a useful way;
- Automatic network configuration audits: self-consistency checks wired to loud alarm bells;
- Automatic generation of DNS records for router interfaces, in the interests of traceroute beautification;
- Automatic generation of graphical maps to help operators visualise live topologies as their networks evolve;
- Gathering data from BGP peers to help in choosing “maximum-prefix” session limits.
Here’s the link : tutorial
Cisco::Accounting 1.01 on CPAN
Posted on augustus 20, 2007
Filed Under Cisco-Accounting, Perl | Leave a Comment
Also our perl module Cisco::Accounting is now available on CPAN.
This module parses and aggregates IP Accounting information from remote Cisco devices or from remote hosts running the IPCAD daemon.
Several other actions are possible like checking and changing the accounting setting on interfaces, clear ip accounting, etc.
The module summarizes all data that it has parsed and also keeps a history.
A front-end to this module is our CIPAT - Cisco IP Accounting Tool.
More information at our products page.
CIPAT 2.00 is now available
Posted on augustus 19, 2007
Filed Under CIPAT, Perl | Leave a Comment
A new version of CIPAT is available for download. CIPAT is Cisco IP Accounting Tool which is a front-end for the Cisco::Accounting perl module.
CIPAT is still a platform independent perl based tool but it has many new features like support for Cisco devices as well as hosts which are running the IPCAD daemon.
Multiple output formats are now supported : HTML, CSV and XML.
A limitation on number of polls or time limit can be set to automatically stop CIPAT and generate reports.
Check out the product page to find out more about the new CIPAT and to see some screenshots.