Sponsored Content
Top Forums Shell Programming and Scripting Syntax error: Bad for loop variable Post 302419739 by kshji on Saturday 8th of May 2010 09:48:15 AM
Old 05-08-2010
Code:
#for ((a=0; a < ${#IPADDRESS} ; a++))
#while is answer for previous need
a=0
cnt=${#IPADDRESS}
while ((a<cnt))
do
        ....
        ((a+=1))
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

syntax error in while loop

Hi, I have the following script (compile_mercury) and I get this error: I have no idea why...and I have written this script completely in linux (bash) and not in windows. **************** ./compile_mercury: line 136: syntax error near unexpected token `done' ./compile_mercury: line 136:... (1 Reply)
Discussion started by: habzone2007
1 Replies

2. Shell Programming and Scripting

Syntax error on variable assignment

Hello all, I have "inherited" a Korn shell script I'm supposed to maintain, and running a "sh -n" on it, I got this syntax error: script.sh: syntax error at line 63: `OB_DEVICE=$' unexpected The line in cause is the first occurence of the usage of perl one-liners. The whole line: ... (2 Replies)
Discussion started by: AdrianM
2 Replies

3. Shell Programming and Scripting

for loop not working - syntax error at line 6: `end of file' unexpected

I have a file called test.dat which contains a b I have written a shell script called test.sh for i in `cat test.dat` do echo $i done When i run this script using sh test.sh I get this message - test.sh: syntax error at line 6: `end of file' unexpected What is the... (3 Replies)
Discussion started by: debojyoty
3 Replies

4. Shell Programming and Scripting

Bash (Ubuntu server): Syntax error: "|" unexpected in While-loop

Hello forum, I hope my problem is easy to solve for someone in here! My main task is to copy a large amount of imap-accounts from one server to another. There is a tool (Perl) called imapsync which does the job exellent. Unfortunately I'm only able to run it on one account at a time. After... (3 Replies)
Discussion started by: primaxx
3 Replies

5. Shell Programming and Scripting

Syntax error: Bad for loop variable

I'm getting an error while running this script. Need help. set -x verbose #echo on clear #clear the screen USERNAME="bbb" PASSWORD="password" SERVER="192.168.1.100" WAIT_TIME=300 FILE_PATH="/home/users/xxx/MMM" # local directory to pickup *.dat file REMOTE_PATH="/Drop_off/xxx/yyy" #... (17 Replies)
Discussion started by: clgz2002
17 Replies

6. Shell Programming and Scripting

IF loop syntax error

I am trying to run a menu option though IF loops. I keep getting errors not allowed the menu to be processed correctly. Currently it will accept the first 2 statements but then crash on the 3rd. The 2nd and 3rd have the same syntax, so I do not understand why it breaks. #!/bin/bash while... (4 Replies)
Discussion started by: Ironguru
4 Replies

7. UNIX for Dummies Questions & Answers

[Solved] Syntax error for awk in a loop

can some one please tell me what is the problem with my syntax:confused: I have 100 files in one folder 1. want to read each of the line by line 2. calculate their number of the words between the first word and the last word of each line 3. create file for each file with number of words... (8 Replies)
Discussion started by: A-V
8 Replies

8. Shell Programming and Scripting

Variable syntax error in $?

hi all , i just tried to take the status of previous command inside the script using echo $?. It throws me a variable syntax error , but when i use echo $? as an individual command it works perfectly . can anyone Please tell me why am getting a variable syntax error when i use echo $?... (7 Replies)
Discussion started by: Rahul619
7 Replies

9. UNIX for Dummies Questions & Answers

Syntax error in for loop

I am using simple for loop, but getting syntax error when I run the code code #!/bin/ksh pls enter number read n for(i=1; i<=n; i++) do echo $i done syntax error + pls enter number + read n (5 Replies)
Discussion started by: stew
5 Replies

10. Shell Programming and Scripting

Bash function using variable in it syntax error

The below bash function uses multiple variables CODING, SAMPLE, SURVEY, andvariant in it. The user selects the cap function and details are displayed on the screen using the $SURVEY variable, the directory is changed to $SAMPLE and the samples.txt is opened so the user can select the sample to... (6 Replies)
Discussion started by: cmccabe
6 Replies
UCARP(8)						      System Manager's Manual							  UCARP(8)

NAME
ucarp -- Automatic IP failover SYNOPSIS
ucarp [-i, --interface=INTERFACE] [-s, --srcip=IPADDRESS] [-v, --vhid=VHID] [-p, --pass=PASSWORD] [-o, --passfile=PASSFILE] [-P, --preempt] [-n, --neutral] [-a, --addr=IPADDR] [-h, --help] [-b, --advbase=SECS] [-k, --advskew=SKEW] [-u, --upscript=SCRIPT] [-d, --downscript=SCRIPT] [-r, --deadratio=RATIO] [-z, --shutdown] [-B, --daemonize] [-f, --facility=FACILITY] [-x, --xparam PARAM] [-S, --ignoreifstate] [-M, --nomcast] DESCRIPTION
ucarp allows a pair of hosts to share common IP addresses in order to provide automatic failover of an address from one machine to another. It is a portable userland implementation of the secure and patent-free Common Address Redundancy Protocol, (CARP), OpenBSD's alternative to VRRP. OPTIONS
ucarp supports the following command line options: -i INTERFACE --interface=INTERFACE The network interface to bind to. -s IPADDRESS --srcip=IPADDRESS The persistent source address, (real IP), associated with this interface. -v VHID --vhid=VHID The id of the virtual server [1-255]. -p PASSWORD --pass=PASSWORD The shared password, (this gets encrypted and is not sent in the clear). -o PASSFILE --passfile=PASSFILE File to read the shared password from. The file specified should contain the password on the first line of the file. -P --preempt Turn on preemptive failover. This causes an instance of ucarp to assume master status right immediately. -n --neutral Do not run the downscript on startup when the initial state is backup. -a IPADDRESS --addr=IPADDRESS The IP address of the virtual server. -h --help Display a brief summary of the command line options. -b SECONDS --advbase=SECONDS Interval in seconds that advertisements will occur, (defaults to 1 second). -k SKEW --advskew=SKEW Advertisement skew [1-255], (defaults to 0). -u COMMAND --upscript=COMMAND Specifies the command to run after ucarp has successfully become master, the interface name gets passed as an argument. Typi- cally a script used to bring up the virtual address, log the result, add routes, clear arp cache entries, etc. -d COMMAND --downscript=COMMAND Specifies the command that is run after ucarp has transitioned to the backup state, the interface name is passed as an argument. This is typically a script used to bring down the virtual interface, log the action, remove routes, etc. -r RATIO --deadratio=RATIO Ratio used by the backup to determine how long to wait for an unresponsive master before considering it dead. -z --shutdown Use of this command causes the command specified by the -d argument to be invoked when ucarp shuts down. -B --daemonize Causes ucarp to detach from the terminal and run in the background as a daemon. -f --facility Set the syslog facility, defaults to daemon. -x PARAMETER --xparam=PARAMETER Specify an extra parameter to be supplied to the up/down scripts. -S --ignoreifstate Ignore unplugged network cables. This option is useful when ucarp nodes are connected with a crossover cable. Without this option the master will transition to backup when the other node is powered down, as it no longer has a link (NO-CARRIER). -M --nomcast Use broadcast instead of multicast advertisements. EXAMPLES
A host with a real IP of 10.1.1.10 configured to be the master in a preemptive configuration with a virtual IP of 10.1.1.252. ucarp -i eth0 -s 10.1.1.10 -v 10 -p secret -a 10.1.1.252 --upscript=/etc/vip-up.sh --downscript=/etc/vip-down.sh -P The backup might be configured something like this. ucarp -i eth0 -s 10.1.1.11 -v 10 -p secret -a 10.1.1.252 --upscript=/etc/vip-up.sh --downscript=/etc/vip-down.sh A machine with a real IP of 192.168.1.19 is the preferred master for a virtual IP of 10.1.12.7, broadcasts are sent every 5 seconds. ucarp -b 5 -s 192.168.1.19 -v 27 -p badpass -a 10.1.12.7 -u /etc/vip-up.sh -d /etc/vip-down.sh -z The hot standby with an IP of 192.168.1.20 uses the following command, (note the advskew of 50 putting it at a disadvantage and making the first machine preferred). ucarp -b 5 -k 50 -s 192.168.1.20 -v 27 -p badpass -a 10.1.12.7 -u /etc/vip-up.sh -d /etc/vip-down.sh -z SIGNALS
Sending the ucarp process a SIGUSR1 will have it log a status line to syslog, eg "Sep 13 12:59:56 localhost ucarp[2654]: [INFO] MASTER on eth0 id 1" or "Sep 13 13:00:25 localhost ucarp[2644]: [INFO] BACKUP on eth0 id 1" Sending the ucarp process a SIGUSR2 will cause it to demote itself from master to backup, pause 3 seconds, then proceed as usual to listen for other masters, and promote itself if necessary. This could be useful if you wish another node to take over master. AUTHOR
ucarp was written by Frank Denis, <j@ucarp.org>. This manual page was written by Eric Evans <eevans@debian.org> for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. UCARP(8)
All times are GMT -4. The time now is 05:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy