How to validate user's input..? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

How to validate user's input..?

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-08-2013
Rashid Khan Rashid Khan is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 27 May 2013, 5:29 AM EDT
Posts: 37
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
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 21 April 2014, 12:00 AM EDT
Location: Amsterdam
Posts: 8,878
Thanks: 230
Thanked 2,141 Times in 1,922 Posts
What programming/scripting language is this?
Sponsored Links
    #3  
Old 03-08-2013
Rashid Khan Rashid Khan is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 27 May 2013, 5:29 AM EDT
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
its perl...
Sponsored Links
Closed Thread

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 12:44 AM.