Sponsored Content
Top Forums Shell Programming and Scripting Help with variable using loop Post 302485704 by Jotne on Thursday 6th of January 2011 02:44:49 AM
Old 01-06-2011
Help with variable using loop

Hi

I have webserver that I do read data from.
Data are stored like this:
Code:
Huston |1
Portland |2
Hazen |1
Minneapolis |4
Albany |1
Pittsburg |1
Albany |1
Huston |1
Portland|1
Hazen |2
Albany |2
Huston |1
Hazen |1

Script
Code:
#!/bin/sh
user="admin"
pass"demo"
server="192.168.1.10"
port="80"
url="http://$user:$pass@$server:$port"

# List of location to log
LOC1="Huston"
LOC2="Hazen"


case $1 in
   config)
        cat <<'EOM'
graph_title Information
graph_vlabel Number
graph_category Data
Count01.label 01 $LOC1
Count02.label 02 $LOC2

EOM
        exit 0;;
esac

# read data into variable
infoservers=`wget -q -O - "$url/folder"`

echo -n "Count1.value "
echo "$infoservers" | grep "|1" | grep $LOC1 | wc -l

echo -n "Count2.value "
echo "$infoservers" | grep "|1" | grep $LOC2 | wc -l

Output
Code:
Count1.value 3
Count2.value 2

This list number of |1 in table from the data I like to get value from.
I have tried to make a loop to do the same, so I do not need to add more lines than the location to look at. I can not get script to show value.


Code:
for i  in `seq 1 2`;
do
       
        echo  -n "Count${i}.value "
	 echo "$infoservers" | grep "|1" | grep $LOC${i} | wc -l
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

variable in a for loop

Hi... i am trying to ping my servers .The hostnames are present in a file .They are separated by spaces in the file . i am doing the following : a=1 for name in $(cat host2 |cut -d" " -f$a) do echo Pinging server $name ping -c5 $name a=$a+1 done It is... (3 Replies)
Discussion started by: sars
3 Replies

2. Shell Programming and Scripting

loop through variable

i have these data in a variable "$test" BUNGA TERATAI 3 5055 ITH 1 1 JADE TRADER 143W ITH 4 4 MOL SPLENDOR 0307A ITH 3 3 the red coloured are the ones that i want to take and compare what I need to do is to take out the red coloured and then compare to another variable, if same then... (0 Replies)
Discussion started by: finalight
0 Replies

3. Shell Programming and Scripting

For loop Variable

Hi, Is it possible to assign one variable to other. eg. v1="table1" v2="20000" I want table1 to assign 20000 table1=20000 Is there any way? Thanks (2 Replies)
Discussion started by: SushilM
2 Replies

4. Shell Programming and Scripting

For loop with one variable as the name of other

Hello all, I find it hard to explain what I need so I will post the code OVZINCLUDE="16810 16811 1689" PLUS_16810="test" PLUS_16811="test" for VPS in $OVZINCLUDE do echo "Dumping VPSes: $OVZINCLUDE " vzdump --compress --snapshot ${PLUS_$VPS} $VPS done ... (2 Replies)
Discussion started by: click
2 Replies

5. Shell Programming and Scripting

how to get the variable in while loop outside of it?

bash-3.00$ cat compare.sh #NOTE : 1.Filename must not have space for the script to work. # 2.Script wont work if symlinks are there instead of proper filenames. #!/bin/bash #set -x #############################VERIFYING THE EXISTENCE OF DUPLICATE FILENAMES IN THE SUPPLIED FILENAMES... (3 Replies)
Discussion started by: munish259272
3 Replies

6. Shell Programming and Scripting

[SHELL: /bin/sh] For loop using variable variable names

Simple enough problem I think, I just can't seem to get it right. The below doesn't work as intended, it's just a function defined in a much larger script: CheckValues() { for field in \ Group_ID \ Group_Title \ Rule_ID \ Rule_Severity \ ... (2 Replies)
Discussion started by: Vryali
2 Replies

7. Shell Programming and Scripting

printing variable with variable suffix through loop

I have a group of variables myLINEcnt1 - myLINEcnt10. I'm trying to printout the values using a for loop. I am at the head banging stage since i'm sure it has to be a basic syntax issue that i can't figure out. For myIPgrp in 1 2 3 4 5 6 7 8 9 10; do here i want to output the value of... (4 Replies)
Discussion started by: oly_r
4 Replies

8. UNIX for Dummies Questions & Answers

Loop and variable not exactly variable: what's wrong

Hello guys, This truly is a newbie question. I'm trying to make a loop to execute simultaneous commands indefinitely while using variable. Here is how my mess looks like (this is just an example): #!/bin/bash IP=`shuf -n 1 IP.txt` # I figured this would be easier to select random lines... (4 Replies)
Discussion started by: bobylapointe
4 Replies

9. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

10. 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
PAPS(1) 						      General Commands Manual							   PAPS(1)

NAME
paps - UTF-8 to PostScript converter using Pango SYNOPSIS
paps [options] files... DESCRIPTION
paps reads a UTF-8 encoded file and generates a PostScript language rendering of the file. The rendering is done by creating outline curves through the pango ft2 backend. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. --landscape Landscape output. Default is portrait. --columns=cl Number of columns output. Default is 1. --font=desc Set the font description. Default is Monospace 12. --rtl Do rtl layout. --paper ps Choose paper size. Known paper sizes are legal, letter, a4. Default is A4. --bottom-margin=bm Set bottom margin in postscript points (1/72 inch). Default is 36. --top-margin=tm Set top margin. Default is 36. --left-margin=lm Set left margin. Default is 36. --right-margin=rm Set right margin. Default is 36. --help Show summary of options. --header Draw page header for each page. --markup Interpret the text as pango markup. --encoding=ENCODING Assume the documentation encoding is ENCODING. --lpi Set the lines per inch. This determines the line spacing. --cpi Set the characters per inch. This is an alternative method of specifying the font size. --stretch-chars Indicates that characters should be stretched in the y-direction to fill up their vertical space. This is similar to the texttops behaviour. AUTHOR
paps was written by Dov Grobgeld <dov.grobgeld@gmail.com>. This manual page was written by Lior Kaplan <kaplan@debian.org>, for the Debian project (but may be used by others). April 17, 2006 PAPS(1)
All times are GMT -4. The time now is 04:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy