Sponsored Content
Top Forums Shell Programming and Scripting Variable increment (of some sort) Post 302646089 by gopajitmalakar on Thursday 24th of May 2012 01:10:20 PM
Old 05-24-2012
Code:
SERVERLIST="1:Server_1a 1:Server_1b 2:Server_2a 2:Server_2b 3:Server_3a 3:Server_3b 4:Server_4a 4:Server_4b"
RETURN_VALUE1=0


for VAR in `print $SERVERLIST`
do
SERVERNAME=`print $VAR | cut -d ":" -f1`
SERVER_NAME=`print $VAR | cut -d ":" -f2`

print "<br>BOUNCING $SERVER_NAME on $SERVERNAME<br>"
print "*******************************************<br><br>"

RETURN_VALUE1=`cmd $SERVERNAME ".././ServerBounce.ksh $SERVER_NAME"`
echo $RETURN_VALUE1
done

if [ $RETURN_VALUE1 -eq 0 ] ; then
        print "\nThe $SERVER_NAME was bounced successfully\n"
elif [ $RETURN_VALUE1 -eq 1 ] ; then
        print "\nThe $SERVER_NAME couldn't be stopped\n"
elif [ $RETURN_VALUE1 -eq 2 ] ; then
        print "\nThe $SERVER_NAME couldn't be started\n"
else
        print "\nThe $SERVER_NAME was not bounced\n"
fi
done

this is the code i am using. the called script will bounce the servers from the list.
the idea is to update this script in a webpage and those if-else can't be run and will only display the last server.
hence i want a variable that will hold the information about what all servers were parsed and increment it once the previous server was bounce and at last will print that the following servers (its content) were bounced.

Moderator's Comments:
Mod Comment Code tags for code, please.

Last edited by Corona688; 05-24-2012 at 02:20 PM.. Reason: na
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

increment a Variable

hi, i want to increment a Variable but it doesnt work. here my codé COUNT=1 COUNT= 'expr $COUNT + 1' i've tried it in the prompt but it print me: expr: syntaxerror What does I make wrong? (4 Replies)
Discussion started by: cengiz
4 Replies

2. Shell Programming and Scripting

Increment variable stored in a file

Hi, I want to write a perl script, which will increment number stored in file. I want to do this without any file handles. I think we have to use some UNIX commands. I am not sure how to do this with file handles. Thanks, (1 Reply)
Discussion started by: solitare123
1 Replies

3. Shell Programming and Scripting

Increment of a variable

Hi All, I have a variable n that stores a number. Eg. echo $n comes out to be 120. I need to print 121 using echo command on n. Please advice. Thanks in advance !! (4 Replies)
Discussion started by: learning_skills
4 Replies

4. Shell Programming and Scripting

Increment a variable in unix bash

Hello There, I have been trying to increment the value of variable to 1, 2, 3 etc. but, it displays 1 1+1 1+1+1 ..... :wall: Could anyone help out with this? for i in *.* do s=`expr $s+1` echo $s j=$i$j mv $i $j done Any help is appreciated? (24 Replies)
Discussion started by: amrutha0303
24 Replies

5. Shell Programming and Scripting

Bash 4.0 increment variable

Hi there everyone! This is my first post so be gentle. I have a small bash script that is extracting 3 line every 3 lines. I got the AWK part but i cant do the loop part. #!/bin/bash export line=`awk 'END { print NR }' btnew` echo $line for i in {1..$line..3} #increment do echo... (2 Replies)
Discussion started by: theodorosGreece
2 Replies

6. Shell Programming and Scripting

How to increment a string variable?

Hi All, I am new to this forum and a novice at shell script. I am trying to write a script to determine each of the NIC configured on a linux system and its speed and Duplex. I came up with the following piece of code: echo `ifconfig -a | grep eth > /home/a/nic.txt` i=`awk -F, '{print... (4 Replies)
Discussion started by: pravin883
4 Replies

7. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

8. Shell Programming and Scripting

Increment date variable

hey guys, I need to incerement the date variable for instance echo `date '+%F %H:%M:00'` this produces 2014-08-02 20:05:00 -I will grant this to : $Datehour and need to assign 1 hr from now to $Datelasthour -the script time will be used to talk to DB system information. however... (4 Replies)
Discussion started by: mo_VERTICASQL
4 Replies

9. UNIX for Beginners Questions & Answers

Script to find a date variable and increment it

Hi, I have parameter file wo_location.prm which has a date variable $last_upd_date= 02032016. I need to write a unix shell script to find that variable and increment it by 1 day. The path to the file is root/dir_lc/shared/param/wo_location.prm and the variable is $last_upd_date. Any... (2 Replies)
Discussion started by: isenhiem
2 Replies
xprehashprinterlist(1x) 												   xprehashprinterlist(1x)

NAME
xprehashprinterlist - Recomputes the list of available printers. SYNOPSIS
xprehashprinterlist [-v] [-h] DESCRIPTION
xprehashprinterlist causes all Xprint servers to recompute (update) their lists of available printers, and update the attributes for the printers. The intended usage of this tool is that a system administrator can run it after changing the printer topology. OPTIONS
-v generate verbose output -h | -? print usage ENVIRONMENT
XPSERVERLIST ${XPSERVERLIST} must be set, identifying the available Xprint servers. See Xprint(7) for more details. EXAMPLES
Update the list of available printers % xprehashprinterlist -v would print: Rehashing printer list on server 'meridian:34' NOTES
xprehashprinterlist rehashes all printer lists of all print servers. Alternatively xset rehashprinterlist may be used to rehash only the list of printers in one print server. SEE ALSO
Xprint(7), X11(7), xset(1x), xplsprinters(1x), xphelloworld(1x), xpxmhelloworld(1x), xpawhelloworld(1x), xpxthelloworld(1x), xpsimplehel- loworld(1x), Xserver(1x), Xprt(1x), libXp(3x), libXprintUtils(3x), libXprintAppUtils(3x), XmPrintShell(3x), XawPrintShell(3x), Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html), Xprint main site (http://xprint.mozdev.org/) 8 October 2004 xprehashprinterlist(1x)
All times are GMT -4. The time now is 02:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy