Skip to main content

Posts

Showing posts from July, 2015

How to: Install and Uninstall Services in Windows

If you’re developing a Windows Service by using the .NET Framework, you can quickly install your service application by using a command-line utility called InstallUtil.exe. To install your service manually Run InstallUtil.exe from the command prompt with your project's executable as a parameter: installutil <yourproject>.exe This tool is installed with the .NET Framework, and its path is %WINDIR%\Microsoft.NET\Framework[64]\<framework_version> . C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe To uninstall your service manually Run InstallUtil.exe from the command prompt with your project's output as a parameter:  installutil /u <yourproject>.exe Sometimes, after the executable for a service is deleted, the service might still be present in the registry. In that case, use the command sc delete to remove the entry for the service from the registry. The syntax used to delete a service is this: sc ...

View Windows command line history

In the Windows command line, press the F7 key to view a history of all the commands that have been entered in that window. Pressing the up or down keys allows you to browse through all commands and once highlighted pressing enter will perform the previous command. Using DOS doskey command Doskey is an MS-DOS utility that allows a user to keep a history of commands used on the computer. Doskey allows frequently used commands to be used without having to type the command each time its needed. Syntax: DOSKEY [/REINSTALL] [/LISTSIZE=size] [/MACROS[:ALL | :exename]] [/HISTORY] [/INSERT | /OVERSTRIKE] [/EXENAME=exename] [/MACROFILE=filename] [macroname=[text]] /REINSTALL Installs a new copy of Doskey. /LISTSIZE=size Sets size of command history buffer. /MACROS Displays all Doskey macros. /MACROS:ALL Displays all Doskey macros for all executables which have Doskey macros. /MACROS:exename Displays all Doskey macros for the given executable. /...
To see list of logged in user type who or w command: [root@localhost ~]# who root tty1 2015-07-15 12:00 root pts/0 2015-07-15 12:05 (:0.0) root pts/1 2015-07-15 12:06 (:0.0) root pts/5 2015-07-28 13:26 (150.236.11.171) [root@localhost ~]# w 13:41:44 up 13 days, 39 min, 4 users, load average: 0.26, 0.50, 0.52 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty1 - 15Jul15 13days 0.12s 0.00s /bin/sh /usr/bi root pts/0 :0.0 15Jul15 13days 14:12 0.05s /bin/bash root pts/1 :0.0 15Jul15 13days 7:27 0.02s /bin/bash root pts/5 150.236.11.171 13:26 0.00s 0.06s 0.00s w Other options You can pass the following options to the who command (taken from the who command man page): Just open a -a, --all same as -b -d --login -p -r -t -T -u -b, --boot time of last system boot -d, --dead print dead processes -H, ...

How to upgrade eclipse in Ubuntu

Download latest Eclipse from the download section of the official website ( http://www.eclipse.org/downloads/ ).  If you have a previous Eclipse version installed, just move it in a backup folder(Just in case anything goes terribly wrong, you can rollback to running good state). Older Eclipse can be found in 2 paths:  /usr/lib/eclipse or  /opt/eclipse  $ sudo mv / usr / lib / eclipse / usr / lib / eclipse-old  /usr/lib/eclipse The package will have the name like:   eclipse-standard-kepler-SR1-linux-gtk-x86_32.tar.gz After you have downloaded the correct package, extract the eclipse.XX.YY.tar.gz using   tar -zxvf eclipse.XX.YY.tar.gz   Copy the extracted folder to /opt cp -r eclipse.XX.YY /opt Create a desktop file in the location /usr/share/applications and install it: gedit eclipse.desktop Copy the following to the eclipse.desktop file. [Desktop Entry] Name=Eclipse Type=Application Exec=eclipse Terminal=false Icon...

Steps to Define Nagios Contacts With Email

Nagios is one of the best open source server and network monitoring solutions available.  Using the flexible nagios framework, you can monitor pretty much anything (including database and custom application). This article, using 4 simple steps, explains how to setup contact definitions who will get notification when a host or service has any issues. 1. Define Generic Contact Template in templates.cfg Nagios installation gives a default generic contact template that can be used as a reference to build your contacts. Please note that all the directives mentioned in the generic-contact template below are mandatory. So, if you’ve decided not to use the generic-contact template definition in your contacts, you should define all these mandatory definitions inside your contacts yourself.   The following generic-contact is already available under /usr/local/nagios/etc/objects/templates.cfg. Also, the templates.cfg is included in the nagios.cfg by default as shown below.   P...

How to Connect to MySQL from Perl

How do I connect to a MySQL database from a perl program? use perl DBI module to connect to a MySQL database as explained below. If you don’t have perl DBI and DBD::mysql module installed, install perl module using cpan as we discussed earlier. # perl -MCPAN -e shell cpan> install DBI cpan> install DBD::mysql On a very high level, you’ll have to do the following three steps to connect to a MySQL database and get data. 1. Connect to the MySQL Database In the DBI module, you’ll use the connect function as shown below. $dbc = DBI->connect($source, $username, $password) DBI->connect function takes the following three arguments: $source – This is in the format of “DBI:mysql:[database]:[hostname]”. Replace the [database] and [hostname] with values from your system. In the example shown below, it is connecting to the database called “mycompany” that is running on the localhost. $username – The username that is used to connect to the MySQL database. $pass...

Introduction to Perl Testing Using Test::Simple and Prove

Testing is an important part of SDLC activity. By automating the testing process, you can save considerable amount of time spent on testing. There are several modules available in Perl to automate testing process. In this introduction article, let us discuss about how to write basic and simple test cases using Test::Simple module in perl. 1. Write Test Cases with Test::Simple You can write test cases in perl using the perl Test::Simple module which has the basic functionality for testing. Before proceed to writing test case, first you need to plan the number of test cases and then the actual test cases. #!/usr/bin/perl use strict; use warnings; use Test::Simple tests => 2; sub hello_world { return "Hello world!"; } sub get_number { return int(rand(1000)); } ok( hello_world( ) eq "Hello world!", "My Testcase 1" ); ok( get_number( ) > 0, "My Testcase 2" ); As shown in the above sample code-snippet, its a simple program that h...

Memory Regression Perl Scripts for Linux

During performance testing of your application you might want to perform some sort of memory regression testing. This article contains two memory regression scripts that are written in perl which will occupy a specific amount of memory for a certain amount of time, for your testing. 1. Basic Memory Regression Script To execute this script, do the following: $ perl memtest.pl 100 The above example will occupy 100 MB of memory, and waits for your input – a simple enter will terminate the script and releases the memory. This way you can let this script occupy the amount of memory you need for as much time as you need. First argument is taken as the amount of memory to be occupied ( in MB ). Note:  Don’t execute this script on any critical system. Be careful while running this script. Don’t give a large memory value to this script. If the amount of memory given is huge or not available, your system might hang. Do ‘vi memtest.pl’ and copy/paste the following perl code to ...

Perl and Excel: How to Read, Write, Parse Excel Files using Perl

If you want to manipulate excel files programmatically, you can use Perl Spreadsheet module, which provides an object interface that makes it easier to create and parse Excel files. Install Spreadsheet WriteExcel Module Method 1: Standard install using make Download the zipped tar file of  Spreadsheet-ParseExcel  and  Spreadsheet-WriteExcel  from cpan. Untar and unzip the module as follows: tar -zxvf Spreadsheet-WriteExcel.tar.gz cd to the directory the tar creates. Execute the steps below to to install the Spreadsheet-WriteExcel module. perl Makefile.PL make make test make install Use the above procedure to install Spreadsheet-ParseExcel also. Method 2: CPAN.pm install If you have CPAN.pm configured you can install the module as follows: perl -MCPAN -e 'install "Spreadsheet::WriteExcel"' perl -MCPAN -e 'install "Spreadsheet::ParseExcel"' For additional installation help refer to: How To Install Perl Modules Manually and Using ...

20 perl programming tips

1. List all Installed Perl Modules from Unix Command Line Get a list of all installed perl modules as shown below. $ perl -MFile::Find=find -MFile::Spec::Functions -Tlw -e 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC' /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/HTML/Filter.pm /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/HTML/LinkExtor.pm /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/HTML/PullParser.pm /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/HTML/Parser.pm /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/HTML/TokeParser.pm ..... In the above example, File::Find  and  File::Spec::Functions  module are used to list all installed modules. -M option  loads the module. It executes  use module  before executing the script -T option  enables taint checking, which instructs perl to keep track of data from the user and avoid doing anything insecure w...