Sponsored Content
Top Forums Shell Programming and Scripting Add new line after 'continue' in if statment Post 303021893 by batchenr on Monday 20th of August 2018 05:03:04 AM
Old 08-20-2018
Quote:
Originally Posted by RudiC
Is that reproducible or a sporadic behaviour?
Is that $LOG file being written to elsewhere?

What is that continue for?
Hey,
LOG is simply a file /tmp/zabbix.csv that after the script i can atteched to email

continue acts like that -
if there is a time out on some IP it does no continue all the loop with this ip
and continue to next ip .

Code:
echo  "IP,Wheel users,Notes" | sudo tee -a $LOG

for IP in $HOST
	do
		echo -n "$IP, "  | sudo tee -a $LOG
		timeout 4s zabbix_get -I $ZBX -p $PORT -s $IP -k "system.run[grep "wheel" /etc/group]" 
		if [ $? -eq 124 ]; then
			echo -e "$RED TIMEOUT $NC" 
			sed -i "/$IP/s/$/ ,TIMEOUT/"  $LOG
			continue
		fi

as this script has more commands after that block
but if i get timeout there is no need for me to do all the loop with this ip
as ill get timeout 5 times. so its continueing to the next ip in the file $HOST
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

what is wrong with my awk statment?

I am looking to find something in the hour(in field $2) of 03:00:07 and 04:00:07 and 05:00:07 and must contain something in field 4... why doesn't below command work? I try to use grep .. but since I am running this in loop, it's best I use the awk .. can someone please advise.. I am pretty... (1 Reply)
Discussion started by: hankooknara
1 Replies

2. Shell Programming and Scripting

if statment, based on retune value

hello im working on a project for the iphone to write a termainal based program we have bsd subsystem installed so have access to most unix command i have a executable called coordinates, which get the coordinates of the iphone when this runs it returns to the terminal the text of... (1 Reply)
Discussion started by: toliver182
1 Replies

3. UNIX for Dummies Questions & Answers

Clarification for egrep statment

Can someone tell me what exactaly the following command is doing - pid_cmd="/usr/ucb/ps -axww | /usr/bin/egrep '${SUNMC2OSS_PATH}/SunMC2OSS\.jar.* sunmc2oss\.SunMC2OSS\$' | /usr/bin/egrep -v egrep | /usr/bin/nawk '{print \$1}'" Is the egrep is to check "sunmc2oss.SunMC2OSS" process inside... (2 Replies)
Discussion started by: puneet1983
2 Replies

4. Shell Programming and Scripting

Continue output redirection on the same line?

I have for i in 1 2 3 4 do echo $i >> test.txt done test.txt contains ... 1 2 3 4 But I want it to contain ... 1234 Any suggestions? (3 Replies)
Discussion started by: Bandit390
3 Replies

5. UNIX for Dummies Questions & Answers

Comparing Special characters (i.e. -,\,/) in an if statment

I need to validate the special characters of a date (the characters between the year and month & month and day). The data filed is being populated by users and read into the script vi an argument. I want to ensure that the date is a '-' (dash) and not a '/' or '\' (slash). The every thing I... (3 Replies)
Discussion started by: angelap
3 Replies

6. Shell Programming and Scripting

continue line in perl script

HI , I am new to the perl , I am using a if condition and in that if condition i am checking 7 variables value. so it continue to second line .And if i user "\" for the continue line it showing error. Example : if(a >9 || b>8 || c> 10 \ d > 11) { print(); } The above statement is... (3 Replies)
Discussion started by: julirani
3 Replies

7. Shell Programming and Scripting

Line in bash script to wait for x feedbacks and then continue

I have a script that runs a console/terminal command on the server and what is want is for each of the multiple success reports fed back from the clients (echo-ed out onto the conosle) to be counted and after x number of reports reboot the server. The Details: The command (program) is... (0 Replies)
Discussion started by: dp123
0 Replies

8. Shell Programming and Scripting

Continue an instruction on more than one line in a script shell ?

Hello, I have a very long instruction to write, but, for lisibility reasons, I would like to cut it on more than one line and comment each lines. is it possible ? thanks :b: (1 Reply)
Discussion started by: shadok
1 Replies

9. Shell Programming and Scripting

Wildcard in a tcsh if statment

Hello everyone I was hoping someone could tell me whether I can use a wildcard inside an tcsh if statement. I am trying to test the argument the user has fed the script and whether it is a .txt file. The Ides behind it is the following if (`echo $1` != *.txt) then echo "wrong... (6 Replies)
Discussion started by: smarones
6 Replies

10. UNIX for Beginners Questions & Answers

Search for word in huge logfile and need to continue to print few lines from that line til find date

Guys i need an idea for one logic..in shell scripting am struggling with a logic...So the thing is... i need to search for a word in a huge log file and i need to continue to print few more lines from that line and the consecutive line has to end when it finds the line with date..because i know... (1 Reply)
Discussion started by: Prathi
1 Replies
continue(1T)						       Tcl Built-In Commands						      continue(1T)

__________________________________________________________________________________________________________________________________________________

NAME
continue - Skip to the next iteration of a loop SYNOPSIS
continue _________________________________________________________________ DESCRIPTION
This command is typically invoked inside the body of a looping command such as for or foreach or while. It returns a TCL_CONTINUE code, which causes a continue exception to occur. The exception causes the current script to be aborted out to the innermost containing loop command, which then continues with the next iteration of the loop. Catch exceptions are also handled in a few other situations, such as the catch command and the outermost scripts of procedure bodies. EXAMPLE
Print a line for each of the integers from 0 to 10 except 5: for {set x 0} {$x<10} {incr x} { if {$x == 5} { continue } puts "x is $x" } SEE ALSO
break(1T), for(1T), foreach(1T), return(1T), while(1T) KEYWORDS
continue, iteration, loop ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTcl | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tcl is available on http://opensolaris.org. Tcl continue(1T)
All times are GMT -4. The time now is 02:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy