Gazz1982 Posted August 8, 2007 Share Posted August 8, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/63961-help-with-a-simple-counter/ Share on other sites More sharing options...
trq Posted August 9, 2007 Share Posted August 9, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/63961-help-with-a-simple-counter/#findComment-318975 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.