Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

How to validate user's input..?

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 03-08-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 28 May 2015, 1:03 AM EDT
Location: Amsterdam
Posts: 10,216
Thanks: 334
Thanked 2,696 Times in 2,412 Posts
What programming/scripting language is this?
Sponsored Links
    #3  
Old Unix and Linux 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 03:57 AM.