Numeric Validation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Numeric Validation
# 8  
Old 12-19-2006
Do you mean the input itself "\" ?
Then use \\
# 9  
Old 12-19-2006
Aju,Anbu,
Thanks for the replies.
Anbu,
For eg: I executed the script as follows by preceeding with \ for input <
Code:
[sabraham@secmstqatmp]# ./shellpgm37.sh \>

Now i get the correct value.

But if i try like
Code:
./shellpgm37.sh  \$%#&*

i get error as

Code:
./shellpgm37.sh  \$%#&*
[1]     19373
ksh: 0:  not found
[sabraham@secmstqatmp]# Error

Is there any other way to do this.

Thanks,
Sumesh
sumesh.abraham
# 10  
Old 12-19-2006
If you have Python installed:
Code:
#!/usr/bin/ksh
input=`echo $1 | /usr/bin/python -c "print raw_input().isdigit()"`
if [ $input == "True" ]; then
   echo "Input is a digit"
fi
....
...
..

# 11  
Old 12-19-2006
./shellpgm37.sh '$%#&*'
use single code while entring special characters as args
# 12  
Old 12-19-2006
Ghostdog74,

Thanks for the reply. I don't have Python.

Aju,Anbu

I tried with single quotes. It worked!! Thanks a lot.
sumesh.abraham
# 13  
Old 08-04-2008
thanks abraham. I really appreciate
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Validation using While and IF

I am learning Shell scripting on own. I am trying to do an assignment to get details from the user like username their individual marks ,DOB and send a report in mail with the Details calculated like total and average. validate_marks() { local Value=$1 if && then return 0 else... (1 Reply)
Discussion started by: JayashreeRobin
1 Replies

2. Shell Programming and Scripting

Value validation

Hi All I am trying to validate a value using if condition requirement is need to check whether its a valid numeric value the input contains ( space, #N/A and negative and positive decimal values and Zeros) if it contains the space, I need to display the error message as space ... (15 Replies)
Discussion started by: tsurendra
15 Replies

3. Windows & DOS: Issues & Discussions

Put the numeric validation in user input when value is 5.1.2.3

Hi I need to put the validation in batch script when user will enter the build number it should be numeric.I can put the validation for numeric values but there is .(dot) in number so it would not take it as numeric. Is it possible we can store it in variable and remove the .(dot) from the... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

4. Shell Programming and Scripting

Name validation

Hi All, I need to write a small piece of code to check the following. name should contain (A-Z), spaces, hyphens & apostrophes I need to generate regular expressions for the same. Please help me out as i am not familiar with regular expressions. (1 Reply)
Discussion started by: lifzgud
1 Replies

5. Shell Programming and Scripting

Validation help

Hi, I am new to Unix shell scripting and need help to add some validation to an existing script. I've made a script that takes two argument (input) but I want the script to display an error message when nothing (null) is entered. So far I managed to validate the fist argument but fail to... (2 Replies)
Discussion started by: zen10
2 Replies

6. UNIX for Dummies Questions & Answers

Find and Replace random numeric value with non-numeric value

Can someone tell me how to change the first column in a very large 17k line file from a random 10 digit numeric value to a non numeric value. The format of lines in the file is: 1702938475,SNU022,201004 the first 10 numbers always begin with 170 (6 Replies)
Discussion started by: Bahf1s
6 Replies

7. Web Development

Validation in php help !

I am validating a form using php script and I want to "echo" the error message near to the text box itself & not below all the controls....Can I Position the display messages ?..Pls help me... (2 Replies)
Discussion started by: gameboy87
2 Replies

8. UNIX for Dummies Questions & Answers

Validation

I'm kinda new in shell scripting. How do i validate an input from a user to conform to requirement. For example, echo "Enter First Name: " read FName echo "Enter Date of Employment (dd/mm/yyyy): " read DoE If the user enters data that is alphanumeric, it accepts it. I hope i've... (1 Reply)
Discussion started by: Allenzo
1 Replies

9. Shell Programming and Scripting

Perl code to differentiate numeric and non-numeric input

Hi All, Is there any code in Perl which can differentiate between numeric and non-numeric input? (11 Replies)
Discussion started by: Raynon
11 Replies
Login or Register to Ask a Question