Jump to content

help with a simple counter!


Gazz1982

Recommended Posts

I am trying to create a simple counter which when running selects a vale from a list

i.e.

The list is:

a1=123

a2=456

a2=789

etc

 

then in the code where is says coordinates= the appropiate value will appear

i.e.

coordinates=a1 therefore coordinates=123,123

coordinates=a2 therefore coordinates=456,456

coordinates=a3 therefore coordinates=789,789

 

This is what i have so far

 

 

#!/bin/sh
#
DIST=60000
H=1.75
DEM=Aber7
####################
#begin loop
for(( i=1; i<=2; i++))
do

#select appropiate coordinate
a1=123
a2=456
##################

echo "calculating Line of Site for Site ${i}"
echo "r.los input=$DEM output=z${i} coordinates=$a1 obs_elev=$H max_dist=$DIST"



################
#end of loop


done
exit

 

Thanks

 

Gary

Link to comment
Share on other sites

Does it have to be in bourne shell? Could be done quite easily in Bash.

 

Something like...

 

#!/bin/bash

# set to size of list
listsize=3

# the list of values.
mylist=(123 456 789)

ran=$RANDOM
let "ran %= $listsize"

echo ${mylist[$ran]}

 

Hope this helps.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.