Sponsored Content
Full Discussion: Multiple while statements?
Top Forums Shell Programming and Scripting Multiple while statements? Post 302576345 by nickzourdos on Thursday 24th of November 2011 10:41:45 AM
Old 11-24-2011
Fixed it!

My syntax for the while loop that checked STATE was bad. In bash, you have to use -a instead of &&:

Code:
while [ "$STATE" != "MI" -a "$STATE" != "OH" -a "$STATE" != "IL" -a "$STATE" != "IN" ];do
   echo "Sorry, that's not an accepted state."
   echo "Enter State: "; read STATE
done

And for some reason, my bash won't recognize the let command... so I have to use expr instead for a counter:

Code:
COUNT=0
while [ "$COUNT" -le "5" ]; do
  echo "Count is less than 5."
  COUNT=`expr $COUNT + 1`
done

The wonders of a good night's sleep.....

Last edited by nickzourdos; 11-24-2011 at 01:03 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

multiple conditions in if statements

Hi all, I'm confused about the proper syntax for multi-conditional if then statements. I'm trying to set limitations on info input on the command line.. i.e. if ] ;then $x=$vr1 else print "You have entered an invalid option." Can someone please clue me in on what is wrong with my syntax;... (3 Replies)
Discussion started by: tim mauger
3 Replies

2. 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

3. 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

4. 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

5. 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

6. Shell Programming and Scripting

multiple echo statements in if condition

Hi , I have a peculiar problem. i have an if block like this if ; then echo " todays date is " ${date} >> log_file echo " file count is " $ count >> log_file mv filename1 filename 2 else echo "no files available ">> log_file fi the echo statement "no files available " is not... (2 Replies)
Discussion started by: wizardofoz
2 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 If statements in bash problem

Hi everyone, May you help me with the correct syntax of the follow bash statements please X=10 if ]; then echo "The value is between 1 and 5" for ((i=1;i<=${X})); do echo $i done else if ]; then echo "The value is between 6 and 10" for ((i=1;i<=${X})); do ... (5 Replies)
Discussion started by: Ophiuchus
5 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
IP-NEIGHBOUR(8) 						       Linux							   IP-NEIGHBOUR(8)

NAME
ip-neighbour - neighbour/arp tables management. SYNOPSIS
ip [ OPTIONS ] neigh { COMMAND | help } ip neigh { add | del | change | replace } { ADDR [ lladdr LLADDR ] [ nud STATE ] | proxy ADDR } [ dev DEV ] ip neigh { show | flush } [ proxy ] [ to PREFIX ] [ dev DEV ] [ nud STATE ] [ vrf NAME ] STATE := { permanent | noarp | stale | reachable | none | incomplete | delay | probe | failed } DESCRIPTION
The ip neigh command manipulates neighbour objects that establish bindings between protocol addresses and link layer addresses for hosts sharing the same link. Neighbour entries are organized into tables. The IPv4 neighbour table is also known by another name - the ARP ta- ble. The corresponding commands display neighbour bindings and their properties, add new neighbour entries and delete old ones. ip neighbour add add a new neighbour entry ip neighbour change change an existing entry ip neighbour replace add a new entry or change an existing one These commands create new neighbour records or update existing ones. to ADDRESS (default) the protocol address of the neighbour. It is either an IPv4 or IPv6 address. dev NAME the interface to which this neighbour is attached. lladdr LLADDRESS the link layer address of the neighbour. LLADDRESS can also be null. nud STATE the state of the neighbour entry. nud is an abbreviation for 'Neighbour Unreachability Detection'. The state can take one of the following values: permanent the neighbour entry is valid forever and can be only be removed administratively. noarp the neighbour entry is valid. No attempts to validate this entry will be made but it can be removed when its lifetime expires. reachable the neighbour entry is valid until the reachability timeout expires. stale the neighbour entry is valid but suspicious. This option to ip neigh does not change the neighbour state if it was valid and the address is not changed by this command. none this is a pseudo state used when initially creating a neighbour entry or after trying to remove it before it becomes free to do so. incomplete the neighbour entry has not (yet) been validated/resolved. delay neighbor entry validation is currently delayed. probe neighbor is being probed. failed max number of probes exceeded without success, neighbor validation has ultimately failed. ip neighbour delete delete a neighbour entry The arguments are the same as with ip neigh add, except that lladdr and nud are ignored. Warning: Attempts to delete or manually change a noarp entry created by the kernel may result in unpredictable behaviour. Particu- larly, the kernel may try to resolve this address even on a NOARP interface or if the address is multicast or broadcast. ip neighbour show list neighbour entries to ADDRESS (default) the prefix selecting the neighbours to list. dev NAME only list the neighbours attached to this device. vrf NAME only list the neighbours for given VRF. proxy list neighbour proxies. unused only list neighbours which are not currently in use. nud STATE only list neighbour entries in this state. NUD_STATE takes values listed below or the special value all which means all states. This option may occur more than once. If this option is absent, ip lists all entries except for none and noarp. ip neighbour flush flush neighbour entries This command has the same arguments as show. The differences are that it does not run when no arguments are given, and that the default neighbour states to be flushed do not include permanent and noarp. With the -statistics option, the command becomes verbose. It prints out the number of deleted neighbours and the number of rounds made to flush the neighbour table. If the option is given twice, ip neigh flush also dumps all the deleted neighbours. EXAMPLES
ip neighbour Shows the current neighbour table in kernel. ip neigh flush dev eth0 Removes entries in the neighbour table on device eth0. SEE ALSO
ip(8) AUTHOR
Original Manpage by Michail Litvak <mci@owl.openwall.com> iproute2 20 Dec 2011 IP-NEIGHBOUR(8)
All times are GMT -4. The time now is 09:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy