One liner with grep to extract the IP addresses from a file.
grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' /path/to/fileThe "-o" option prints only the matched parts.
One liner with perl:
perl -ne 'print if s/.*((\d{1,3}\.){3}\d{1,3}).*/\1/' /path/to/file
PerlPerl Scripts and tricks... Extract IP addressSubmitted by sandip on Tue, 05/15/2012 - 15:22One liner with grep to extract the IP addresses from a file. grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' /path/to/fileThe "-o" option prints only the matched parts. One liner with perl: perl -ne 'print if s/.*((\d{1,3}\.){3}\d{1,3}).*/\1/' /path/to/filemunin-node and postgresql plugins setupSubmitted by sandip on Sun, 02/05/2012 - 19:37While setting up munin to monitor postgresql, I was getting "[DBD::Pg not found, and cannot do psql yet]" when running `munin-node-configure --suggest | grep postgres`. I confirmed that the rpm package "perl-DBI-1.52-2.el5" was indeed installed. However, when I ran a test against the module, it failed with: # perl -MDBD::Pg -e 1On checking the library, it returned with "libpq.so.4 => not found": # ldd /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Pg/Pg.soIndeed libpq.so.4 was missing since postgresql90-libs was installed which only includes "libpq.so.5". To get libpq.so.4, "compat-postgresql-libs" package needed to be installed. Once installed the perl module test passed and I was able to get the munin plugins linked using: # munin-node-configure --shell | grep postgres | shIP range to CIDR conversionSubmitted by sandip on Thu, 05/15/2008 - 10:19I've often had to convert IP range with netmask to a CIDR notation. Below is a quick perl script to help with the conversion: #!/usr/bin/perl -wInstalling Bugzilla on an ISPConfig siteSubmitted by sandip on Thu, 06/07/2007 - 16:34These are some notes I had taken down during the installation of Bugzilla on a server with ISPConfig hosting control panel: Requirements:# yum install mysql-devel gd-devel libpng-devel libjpeg-devel freetype-devel libdbm-develCreate Site:Site was created via the ISPConfig control panel with "web6_bugs" as the admin user and "web6" as the group. Install:$ cd /var/www/web6Apache with mod_perl need the below directives in httpd.conf: PerlSwitches -I/var/www/web6/web -w -TRuns a lot faster, but is a memory hog. Suggested to turn off KeepAlive in apache when running mod_perl. Crontab Entry:# BugzillaHowto check and install missing perl modules...Submitted by sandip on Fri, 06/10/2005 - 14:20
# perl -MModule::Name -e 1See documentation of the module if installed. # perldoc Module::NameOpen CPAN shell: # perl -MCPAN -e shellTo reconfigure the shell if needed. cpan>o conf initInstall an available module. cpan> install Module::NameForce install if test fails. cpan> force install Module::NameTo manual install perl modules. # perl Makefile.PL # make # make test # make install Web Client Programming with Perl - Automating Tasks on the WebSubmitted by sandip on Sat, 05/08/2004 - 00:40An excellent free ebook which imparts knowledge on how the Web technically works and how to write software that is more flexible, dynamic, and powerful than the typical web browser using perl and perl tk. The goal is to give you the ability to retrieve, manipulate, and redistribute web-based information in an automated fashion. Server Environment VariablesSubmitted by sandip on Fri, 04/30/2004 - 23:53One of the methods that the web server uses to pass information to a cgi script is through environmental variables. These are created and assigned appropriate values within the environment that the server spawns for the cgi script. They can be accessed as any other environmental variable, like with %ENV{'VARIABLE_NAME'} (in Perl). Many of them, contain important information, that most cgi programs need to take into account. To get a list of such environment variables, use the below script:
Perl Compatible Regular Expressions ManualSubmitted by sandip on Tue, 04/13/2004 - 11:44PCRE was originally written for the Exim MTA, but is now used by many high-profile open source projects, including Python, Apache, PHP, KDE, Postfix, Analog, and nmap. Other interesting projects using PCRE include Ferite, Onyx, Hypermail, and Askemos. CGI:IRCSubmitted by sandip on Sun, 01/04/2004 - 08:32CGI:IRC - is a Perl/CGI program that lets you access IRC from a web browser, it is designed to be flexible and has many uses such as an IRC gateway for an IRC network, a chat-room for a website or to access IRC when stuck behind a restrictive firewall. ShopCMS Paypal Shopping CartSubmitted by sandip on Fri, 12/05/2003 - 09:23ShopCMS Paypal Shopping Cart is a catalog manager and shopping cart that features two levels of categories, a collapsible navigation menu, full PayPal integration, customizable templates with detailed style sheets, a WYSIWYG HTML editor for product info, compatibility with most Web servers and operating systems, and support for mod_perl. It handles image uploading and cloning of existing Items, includes a browser-based administration control panel, and ranks popular products. |
User loginRecent blog posts
Who's onlineThere are currently 0 users and 20 guests online.
|