Sponsored Content
Top Forums Shell Programming and Scripting How to validate user's input..? Post 302777591 by Rashid Khan on Friday 8th of March 2013 07:04:25 AM
Old 03-08-2013
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.....
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

validate input from user for file name

Hello, This may have been addressed already somewhere, however I am looking for the easiest/shortest way to validate a response from a user for a file name. The file name should not have any of the following characters ~`!@#$%^&*()_-+={|\:;"'<,>.?/ Further the response should not have any... (2 Replies)
Discussion started by: jerardfjay
2 Replies

2. Shell Programming and Scripting

How to validate input values

Hi How would i validate value of a variable whether it is number,date or string Thanks in advance Sas (5 Replies)
Discussion started by: SasDutta
5 Replies

3. Shell Programming and Scripting

validate input

the user inputs names that have to be inside square brackets I want to check if the user puts the brackets and if not ask him to re-enter the names (9 Replies)
Discussion started by: DDoS
9 Replies

4. UNIX for Dummies Questions & Answers

BASH validate user input

Hey, im trying to validate a user input and need some help. The input needs to be just a single letter. Im using a case to so this eg: read answer case $answer in *) echo "OK" ;; *) echo "This is a number" read answer ;; *) echo... (2 Replies)
Discussion started by: 602chrislys
2 Replies

5. Shell Programming and Scripting

Validate and sort input

Hi, This will most likely be a simple answer. Currently I have a situation where my script will be sent various options: -o1 -o2 -oe3@somthing.com Now, if I want to run a certain command based on the option I am sent, I am doing the following. for o in $(echo $options) do if ... (3 Replies)
Discussion started by: stuaz
3 Replies

6. Shell Programming and Scripting

How to validate input parameters?

Hi, I wonder how I can know if the input parameters to the script are numbers or text Thanks (11 Replies)
Discussion started by: Gengis-Kahn
11 Replies

7. Shell Programming and Scripting

Is there a simpler way to validate user input for float?

I'm trying to only read price (FLOAT (i.e 1.10, 3.14, etc etc)) If the input is just an integer, I will add a .00 behind. (i.e 3 becomes 3.00 , 20 becomes 20.00) If the input is without 2 decimal places, I'll add a 0. (i.e 3.1 becomes 3.10) I tried using the below code, it works but I don't... (6 Replies)
Discussion started by: andylbh
6 Replies

8. Shell Programming and Scripting

Another validate input Question.

I'm writing a bash shell script to 'help' me post to susepaste (I can NEVER remember the time options). Here's the code: #!/bin/bash ########## # # Project : personal script. # Started : Wed Aug 03, 2011 # Author : Habitual # Description : susepaste c-li script with user... (5 Replies)
Discussion started by: Habitual
5 Replies

9. Shell Programming and Scripting

[bash] how is proper way to validate user input

hi all, i have a script that need user input provide all variables that needed to complete a job. this is my current script: echo "type file source and it full path :" read INPUTFILE if || ; then echo "ERROR: you didn't enter a file source or file source is not... (2 Replies)
Discussion started by: makan
2 Replies

10. Shell Programming and Scripting

Validate input files daily

We have a job which we need to run on daily bases, before loading data in a table we need to validate whether the input file is received or not. Daily client will place the files in a particular path.Below files which I need to process for 04/01/2013(Load date).... (2 Replies)
Discussion started by: katakamvivek
2 Replies
MSGC(1) 						    BSD General Commands Manual 						   MSGC(1)

NAME
msgc, msg_window, msg_string, msg_clear, msg_standout, msg_standend, msg_display, msg_display_add, msg_prompt, msg_prompt_add, msg_prompt_win, msg_prompt_noecho, msg_row, msg_table_add -- simple message list compiler SYNOPSIS
msgc [-o name] file #include "msg_defs.h" void msg_window(WINDOW *window); const char * msg_string(msg msg_no); void msg_clear(void); void msg_standout(void); void msg_standend(void); void msg_display(msg msg_no, ...); void msg_display_add(msg msg_no, ...); void msg_prompt(msg msg_no, const char *def, char *val, int max_chars, ...); void msg_prompt_add(msg msg_no, const char *def, char *val, int max_chars, ...); void msg_prompt_win(msg msg_no, WINDOW *win, const char *def, char *val, int max_chars, ...); void msg_prompt_noecho(msg msg_no, const char *def, char *val, int max_chars, ...); int msg_row(void); void msg_table_add(msg msg_no, ...); DESCRIPTION
This implements a curses based message display system. A source file that lists messages with associated names is given to msgc and produces both a .c and a .h file that implement the menu system. The standard root name of the files is msg_defs. The -o name can be used to specify a different root name. ENVIRONMENT
MSGDEF Can be set to point to a different set of definition files for msgc. The current location defaults to /usr/share/misc. FILES
/usr/share/misc/msg_sys.def SOURCE DESCRIPTION
The format is very simple. Each message is started with the word 'message' followed by the name of the message. The body of the message is next and is started by a { and closed by a }. The braces are not part of the message. Everything, including newlines between the braces are part of the message. MESSAGE FUNCTIONS
The defined messages are used through calls routines that manipulate the messages. You first need to set the curses(3) environment up and then tell the message system which window to use for displaying message by calling the function msg_window(). All variable argument lists in the functions are used as are arguments to sprintf(3). The messages may have sprintf(3) conversions in them and the corresponding parameters should match. Messages are identified by name using the notation 'MSG_name' where ``name'' is the name in the message source file. (The definitions are accessed by including the generated .h file into a source file wanting to use the message rou- tines.) The function msg_string() just returns a pointer to the actual message string. The functions msg_clear(), msg_standout() and msg_standend() respectively clear the message window, set standout mode and clear standout mode. The functions msg_display() and msg_display_add() cause a defined message to be displayed in the message window and does the requested con- versions before printing. The difference is that msg_display() clears the window before displaying the message. These functions fill para- graphs for readability. The msg_table_add() function behaves like msg_display_add() but does not fill text. The remaining functions deal with a prompt facility. A prompt message is either taken from the message directory or from a given string. The message is processed with sprintf(3) and then displayed. If the parameter def is non-NULL and not a string of zero length, a default value is printed in brackets. The user is allowed to type in a response. If the user types just the newline character, the default is returned in the value. The parameter max_chars is the length of the parameter val, where the results are stored. The parameters def and val may point to the same character array. If the default is chosen, the character array is not changed. The functions msg_echo() and msg_noecho() control whether the prompt routine echo or don't echo the input that is typed by the user. msg_prompt_win() uses the specified curses window instead of the default one. msg_row() return the current row - i.e.: getcury(msg_win) + getbegy(msg_win). AUTHORS
Philip A. Nelson for Piermont Information Systems Inc. BSD
September 25, 2003 BSD
All times are GMT -4. The time now is 02:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy