Easy commandline argument parsing in shell script

This item was filled under [ Shell Scripting ]

Here is a fairly easy method which can parse all input arguments passed to a shell script in commandline. This block of code can be either included in top of the script or source it from an external file.

Using this code within a shell script is very simple, just needs to define a global variable named ARGS_INPUT_FORMAT and set appropriate values to it. The argument parsing code will read this variable and set appropriate inputs as well as outputs.

Set values to the variable ARGS_INPUT_FORMAT as shown below.

Continue reading...

Tagged with: [ , ]

Turn your website into maintenance mode - SEO friendly solution using .htaccess file

This item was filled under [ Webmaster HOWTOs ]

Here is a simple trick which enables to turn your website into maintenance mode using .htaccess file.

If you want to give an informative message saying "We are under maintenance", create a custom HTML page containing the message and put it in the website root. For e.g., we create an HTML page called "under-maintenance.html" and place it inside the website root, so that we can access it through the URL http://www.yourdomain.com/under-maintenance.html

Setup status "503" and header "Retry-After"

Depending on the maintenance duration, we also have to care about the search engines which may visit the website during maintenance. For doing this, we will send an http status code 503, "Service Unavailable", along with the HTML page containing maintenance information. Also, we will inform search engines, visit the website only after the maintenance is completed.

Continue reading...

Tagged with: [ , ]

Understanding Cache control and enabling it for optimal results

This item was filled under [ Webmaster HOWTOs ]

Cache control is a mechanism used to control the caching behavior of a web browser. By default, all modern browsers know what content to be cached and reuse when again it requires. Browsers are using their own unique algorithms to decide whether the cached content can be safely re-used or not. Normally, browsers cache all the images in a web page and just check its freshness against the server's copy whenever a new request comes. If the content is modified on server, it will simply re-download it.

The mechanism of content caching is pretty simple but an effective configuration of server will only allow utilizing this feature fully and properly.

Continue reading...

Tagged with: [ ]

HTTP / Web server troubleshooting using Wget.

This item was filled under [ Webmaster HOWTOs ]

There are few useful options to the powerful wget command, a non-interactive Linux/Unix command line downloader which helps you identifying various http server responses, performance related issues and optional feature supports.

For probing an http server and identifying its response, we can use the --spider option.

wget --spider http://www.google.com

--06:24:36-- http://www.google.com/
Resolving www.google.com... 74.125.53.103, 74.125.53.99, 74.125.53.104, ...
Connecting to www.google.com|74.125.53.103|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
200 OK

Continue reading...

Tagged with: [ , ]

kSar - an easy sar grapher utility

This item was filled under [ Application Reviews ]

kSar is an easy to use application for creating graphical reports from your sar daily report. kSar is written in java and it supports generating the report in PDF, HTML, CSV, JPG and PNG formats.

Screenshot

kSar CPU Statistics
kSar CPU Statistics

Sar is a system activity reporting tool which comes with the sysstat rpm package. Sar will collect your system activities every 10 minutes and store in /var/log/sa/saXX where XX is the zero-padded two digit day of month. Once you have sar is ready in your linux system, kSar can read the daily report file generated by sar from /var/log/sa/sarXX and generate the graphical report.

kSar can work in GUI as well as in CLI modes. GUI mode gives you the visualization of sar generated report with customizable easy to read graphs.

The CLI mode gives you the flexibility of reading sar reports from the specified input file and create graphical output in various formats like PDF, HTML or images. The command line interface will be useful if you want to generate a report on daily basis and send it via email using cron job.

Continue reading...

Tagged with: [ , ]

FTP firewall issues in Passive mode

This item was filled under [ Networking HOWTOs, Security HOWTOs ]

In Linux, the default FTP mode is "Passive" where it is "Active" in Windows. The Passive mode FTP causes client to connect to high port in server. This high port is unpredictable and can range from 1024 to 65535 (high ports). Different client connections use different ports and it is difficult to identify the port which needs to be opened in server side to establish data connection from client in Passive mode. Normally if you use a firewall (say iptables) and block all the ports except 21 (FTP control port), the data transfer between client and server will be blocked in Passive mode.

Continue reading...

Tagged with: [ , ]