how to run an already made script run against a list of ip addresses solaris 8 question

how to run an already developed script run against a list of ip addresses solaris 8 question.

the script goes away and check traffic information, for example

check_GE-VLANStats-P3 1.1.1.1

and returns the results ok.

how do I run this against an ip list? i.e a list of 30 ip addresses

If you have ssh enabled, try this...

IPLIST="192.168.1.1 192.168.1.2"
for ip in $IPLIST
do
  ret=$( ssh $ip /full/path/to/script )
  echo $ret
done

How to setup SSH, please search the forum! If you don't want SSH, use rsh or rlogin which is less secure.

--ahamed

1 Like

# IPLIST="ip_list"
[root@V440]# for ip in $IPLIST
> do
> ret=$( ssh $1 /opt/tools/utils/HUB/GEW-VLANStats-P3 )
> echo $ret
> done
bash: ssh: command not found

You don't have ssh? :eek:
Paste the output of which ssh

--ahamed

1 Like

do you know why this will be ?

[name@V440]# ls
check_GE-VLANStats-P3

[name@V440]# more check_GE-VLANStats-P3
/opt/tools/utils/commands $1 /opt/tools/utils/HUB/GEW-VLANStats-P3

[name@V440]# pwd
/opt/tools

---------- Post updated at 01:34 PM ---------- Previous update was at 01:32 PM ----------

ssh works to the ip addresses ok when running the script on an individual ip address

name@V440]# which ssh
/usr/local/bin/ssh

Use the full path of ssh in that case

ret=$( /usr/local/bin/ssh $ip /opt/tools/utils/HUB/GEW-VLANStats-P3 )

Please make sure the variable IPLIST is populated correctly with the required IP address only separated by space as shown in the previous post.
Also, why did you use $1 in your code?

--ahamed

1 Like

of that script it will

#ssh -l 1.1.1.1
enter password
#telnet 169.1.1.1
enter user & password
#aux_stats -v
and print output (need it run twice i.e aux_stats -v to produce a comparison)

---------- Post updated at 01:40 PM ---------- Previous update was at 01:38 PM ----------

required ip address of a particular site? I need it to compare from the list ip_list?

$1 i copied this from $1 /opt/pds-tools/utils/HUB/GEW-VLANStats-P3 output

---------- Post updated at 01:47 PM ---------- Previous update was at 01:40 PM ----------

I think you misunderstood let me explain, the script runs ok against 1 ip address

i.e

check_GE-VLANStats-P3 1.1.1.1

and produces output ok.

I need to run it against and ip list

mmm... Try this...

IPLIST="1.1.1.1 1.1.1.2"
for ip in $IPLIST
do
  check_GE-VLANStats-P3 $ip
done

--ahamed

1 Like

But I need it to check against a file (ip_list) which has 30 ip's in it ? can I point it to a filename without putting all those ip addresses in?

also say I wanted it to check 1.1.1.1 and then 1.1.1.1 again for comparison i.e right next to each other

while read ip
do
  check_GE-VLANStats-P3 $ip
done < ip_list

I didn't understand your second point

--ahamed

1 Like

i.e say i have a list of 30 ip's i want it do to the first ip check then I want it to repeat the first one then move onto the second ip on the list, repeat the check of the second one and then move onto the third....and so on..

---------- Post updated at 02:11 PM ---------- Previous update was at 02:09 PM ----------

what does the following mean/do

while read ip
$ip
done < ip_list

That is a simple while loop. It reads each line from the file ip_list into the variable ip. And within the loop, it is being echo-ed here. You missed the do and echo.

And regarding you second requirement, I still didn't get you. You want to check if the first IP was ok and then continue with the next IP's? or is it something else?

--ahamed

1 Like

1.1.1.1
2.2.2.2
3.3.3.3

check each ip twice before moving onto the next one so

1.1.1.1
1.1.1.1
2.2.2.2
2.2.2.2
3.3.3.3
3.3.3.3

while read ip
do
  check_GE-VLANStats-P3 $ip
  check_GE-VLANStats-P3 $ip
done < ip_list

--ahamed

1 Like

what variable is $ip ? what can be in it?

while read ip
do
   echo $ip
done < ip_list

can you put comments need to get it into my head

Why don't you try executing the code and see?
$ip here will have values 1.1.1.1 2.2.2.2 etc depending on the contents of the file ip_list!

--ahamed

1 Like

yes works a treat - excellent.

please can I have comments on while code pls pls pls...

What comment?
It is obvious no?
Or what don't you understand?

1 Like

ok here's my understanding...

while read ip (while read is a linux script ? ip is there any significance to internet protocol?
do (ok do the following scripts twice)
  check_GE-VLANStats-P3 $ip (then echo to my variable $ip)
  check_GE-VLANStats-P3 $ip
done < ip_list

(when ip_list is finished then were done?)

?

While <condition true>;do;done : In this case while there is an IP to read from input; do;etc...
the done is executed after the last line given in input (< sign)
This is the standard way to NOT use cat (useless use of cat...) which would have been like:

cat ip_list | while read IP
do
..
done

I put the bit of code here so you see the "done" and so you can compare with its counterpart you know

1 Like