Input Validation Shell Script

Technical, development No Comments »

I am Back but this time for some code sharing…..

I have been working on Unix Shell scripts for standalone work and came across the need for various types of input validation.

The basic need of Input validation comes when we have some other program’s depending on the input and those programs being sensitive to type of data  being send to them.

so i have compiled some neat hacks for this specific purpose….

You can check at the bottom for a detailed usage of the functions that i have created.

A direct download is also available here

function num_check()

{

read -p "$1" as

until expr $as - 1 >>/dev/null 2>/dev/null

do

read -p "$2 should be numeric please enter again" as

done

echo $as

}

function char_check()

{

read -p "$1" as

while expr $as - 1 >>/dev/null 2>/dev/null

do

read -p "$2 should not be numeric please enter again" as

done

echo $as

}

function null_check()

{

read -p "$1" as

while [ -z $as ]

do

read -p "$2 should not be null " as

done

echo $as

}

function alphacheck()

{

read -p "$1" as

while echo $as | grep [0-9!@#$%^&*()-_|] 2>>/dev/null >>/dev/null

do

read -p "$2 should be alphabet only" as

done

echo $as

}

#

#       sample calling for the script

#

#

#z=`num_check "Please enter the no" "Customer no" `

#echo $z

#echo `expr $z + 1`

#y=`char_check "Please enter the name" "Customer name"`

#echo $y

#echo $y | wc -c

#x=`null_check "Please enter enrollment no" "enrollment no"`

#q=`alphacheck "Please enter the name" "Customer name"`

#echo $q

I hope this helps someone

Waiting for comments and corrections……….

wordpress plugin : my profiles

development 18 Comments »

If you have account at more then 5-10 sites and wish to connect between them its a lot more then just pain to remember each site. After searching web for more then hours i came only one plugin which supported listing my profiles at the same place, but that too was limited in choice.

so finally i decided to create a plugin of my own, so her it is

WORDPRESS : My Profiles

Plugin currenty hosted at my site, will add it to wordpress plugin repository in a day or two as well as trying tomake it available at sourceforge.

Plugin is released under GPL Scheme.

INSTALLATION : its quite straight forward,

download the zip here,

extract it in your wp-content/plugins folder and enable it in your admin panel,

to show your profiles just enable my-profiles widget,

setting’s are available in setting’s panel.

you just have to enter your nicknames in the list and your profile url along with site’s favicon will get placed in your widget.

Hope this help’s some one else like it is helping me.

Blog Hosted on Wordpress & WP Theme & Icons by N.Design Studio. Modified by Anant Shrivastava
Entries RSS Comments RSS Log in