Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-08-2013
Registered User
 
Join Date: Mar 2013
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
How to validate user's input..?


Code:
 $Input_filename=$ARGV[0];
	
if (!-d $Input_filename  && ! -e $Input_filename)
{
	print "USAGE: Please enter '$ABCD/def/dsed.txt' as an arguement \n";
	exit;
}


1. Input Is suppose to be something like "$ABCD/def/dsed.txt".
if the input is wrong the script should throw an ERROR message.

if user enters $ABCD only, error message should be displayed.

if the user enters "$ABCD/def/" a error message shold be displayed.

do i need any regex to check it out??

PLEASE SUGGEST.....
Sponsored Links
    #2  
Old 03-08-2013
Scrutinizer's Avatar
Moderator
 
Join Date: Nov 2008
Location: Amsterdam
Posts: 7,350
Thanks: 144
Thanked 1,755 Times in 1,592 Posts
What programming/scripting language is this?
Sponsored Links
    #3  
Old 03-08-2013
Registered User
 
Join Date: Mar 2013
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
its perl...
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[bash] how is proper way to validate user input makan Shell Programming and Scripting 2 09-24-2012 02:51 AM
Is there a simpler way to validate user input for float? andylbh Shell Programming and Scripting 6 01-17-2011 12:34 PM
BASH validate user input 602chrislys UNIX for Dummies Questions & Answers 2 07-28-2009 04:10 AM
validate input DDoS Shell Programming and Scripting 9 02-07-2009 05:21 PM
validate input from user for file name jerardfjay Shell Programming and Scripting 2 08-11-2005 11:53 AM



All times are GMT -4. The time now is 02:58 AM.