Sponsored Content
Top Forums Shell Programming and Scripting multiple conditions in if statements Post 20276 by Deepa on Wednesday 24th of April 2002 12:51:21 AM
Old 04-24-2002
Try this !

if [ $i = "+" -o $i = "-" -o $i = "/" -o $i = "%" ]; then
$x=$vr1
else
print "You have entered an invalid option."
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

multiple 'if' statements out of array

I want to do multiple comparisons on a series of numbers from an array: I send the numbers in file1 through want to print out some info from file2 based on some conditions. The syntax just isn't correct??? awk ' NR==FNR{ a=$0 next ... (2 Replies)
Discussion started by: dcfargo
2 Replies

2. Shell Programming and Scripting

if then statements with two conditions...?

Is it possible to setup two conditions for an if then statement in a pbash script? For example, depending on the text value of a variable I parse out of an xml file, I want to assign it a numerical values. Example: if ; then VAR="25" fi if ; then VAR="25" fi Can these two... (3 Replies)
Discussion started by: audiophile
3 Replies

3. Shell Programming and Scripting

Help regarding multiple conditions

Hi All, I am new to shell scripting. Can any one say what is wrong in this if statement, that uses multiple conditions if then *************** else if ( -z $pcs && "$night_time_calc" > "$night_time" ) then ******************************** ... (4 Replies)
Discussion started by: ssenthilkumar
4 Replies

4. Shell Programming and Scripting

How do I execute multiple statements within If then else

Please help me. I have been doing this for several hours. Here is the code if then echo a b c d >> file.txt echo 1111 >> file.txt fi The reason I want the two echo is because I want these statements printed on multiple lines. I keep getting error . First it tells me... (2 Replies)
Discussion started by: asemota
2 Replies

5. Shell Programming and Scripting

Running multiple if statements

Hi, Hav automated a process, and it is working fine. for first process alone status = ` ps -ef |grep a ` if then echo " Success" > temp/logfile else echo " Failure" > temp/logfile fi Now I hav to write script to automated some 2 process and then send mail using cron.. ... (5 Replies)
Discussion started by: NehaKrish
5 Replies

6. Shell Programming and Scripting

execute multiple statements in if-else

how can we execute multiple statements in else condition i have if then statement else statements fi in else condition i have multiple statements but it executing only one statement is there any way to execute multiple statements (4 Replies)
Discussion started by: nani1984
4 Replies

7. Shell Programming and Scripting

Multiple if Statements

Hi All, I need to check for 3 conditions and if all the 3 are not satified need to say that services are not running.... is the below code correct. #********** Check to see if Service 1 is still running************** if then echo "$datetimestamp: Service1 is not running" >>... (4 Replies)
Discussion started by: ch33ry
4 Replies

8. Shell Programming and Scripting

Multiple while statements?

I'm working on a script for class as a final project. We have to ask for values (city, state, zip) five times, but the state can only be MI, IN, IL, or OH. I'm trying to do this with a while loop inside of a while loop, but I have no idea how to do it properly. Here's what I have so far: ... (3 Replies)
Discussion started by: nickzourdos
3 Replies

9. UNIX for Dummies Questions & Answers

Multiple if statements

exmaple: file1 and file2 has 1 bit if then exit else send out email fi if then exit else send out email fi it exits the 1st if. did not continue with my 2nd if. thanks in advanced. Please use CODE tags are suggested on every page when you post an item in... (7 Replies)
Discussion started by: lawsongeek
7 Replies

10. Shell Programming and Scripting

Using multiple 'for' statements

Hello, I am new to scripting and I am trying to write a simple script that creates users and adds their passwords from two files; one a user list file and another a password list file. For example, I have two files already. $ cat file1 andy stephane aby paul $ cat file2 123 234... (4 Replies)
Discussion started by: FemoTheDon
4 Replies
FormValidator::Simple::Results(3pm)			User Contributed Perl Documentation		       FormValidator::Simple::Results(3pm)

NAME
FormValidator::Simple::Results - results of validation SYNOPSIS
my $results = FormValidator::Simple->check( $req => [ name => [qw/NOT_BLANK ASCII/, [qw/LENGTH 0 10/] ], email => [qw/NOT_BLANK EMAIL_LOOSE/, [qw/LENGTH 0 30/] ], ] ); if ( $results->has_error ) { foreach my $key ( @{ $results->error() } ) { foreach my $type ( @{ $results->erorr($key) } ) { print "invalid: $key - $type "; } } } DESCRIPTION
This is for handling resuls of FormValidator::Simple's check. This object behaves like Data::FormValidator's results object, but has some specific methods. CHECK RESULT
has_missing If there are missing values ( failed in validation 'NOT_BLANK' ), this method returns true. if ( $results->has_missing ) { ... } has_invalid If there are invalid values ( failed in some validations except 'NOT_BLANK' ), this method returns true. if ( $results->has_invalid ) { ... } has_error If there are missing or invalid values, this method returns true. if ( $results->has_error ) { ... } success inverse of has_error unless ( $resuls->success ) { ... } ANALYZING RESULTS
missing no argument When you call this method with no argument, it returns keys failed 'NOT_BLANK' validation. my $missings = $results->missing; foreach my $missing_data ( @$missings ) { print $missing_data, " "; } # -- print out, for example -- # name # email key When you call this method with key-name, it returnes true if the value of the key is missing. if ( $results->missing('name') ) { print "name is empty! "; } invalid no argument When you call this method with no argument, it returns keys that failed some validation except 'NOT_BLANK'. my $invalids = $results->invalid; foreach my $invalid_data ( @$invalids ) { print $invalid_data, " "; } # -- print out, for example -- # name # email key When you call this method with key-name, it returns names of failed validation. my $failed_validations = $results->invalid('name'); foreach my $validation ( @$failed_validations ) { print $validation, " "; } # -- print out, for example -- # ASCII # LENGTH key and validation-name When you call this method with key-name, it returns false if the value has passed the validation. if ( $results->invalid( name => 'LENGTH' ) ) { print "name is wrong length! "; } error This doesn't distinguish 'missing' and 'invalid'. You can use this like 'invalid' method, but this consider 'NOT_BLANK' same as other validations. my $error_keys = $results->error; my $failed_validation = $resuls->error('name'); # this includes 'NOT_BLANK' if ( $results->error( name => 'NOT_BLANK' ) ) { print "name is missing! "; } if ( $results->error( name => 'ASCII' ) ) { print "name should be ascii code! "; } SEE ALSO
FormValidator::Simple AUTHOR
Lyo Kato <lyo.kato@gmail.com> COPYRIGHT AND LICENSE
This library is free software. You can redistribute it and/or modify it under the same terms as perl itself. perl v5.14.2 2011-12-08 FormValidator::Simple::Results(3pm)
All times are GMT -4. The time now is 05:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy