need help writing a script in Windows

Hi,

On Windows 2003, we have over 100 servers. I need to find NICs settings. I am using "SNMPUTIL" to get this.

If there is any other easy way to do this please do let me know.

Check the value of the output to see if its 2, if its not 2 the issue the command again increasing the end of the commands number by 1

snmputil get localhost public .1.3.6.1.4.1.232.18.2.3.1.1.34.2
So the output will either be the below or if its the last NIC you will get

 
d:\server1>snmputil get localhost public .1.3.6.1.4.1.232.18.2.3.1.1.34.1
Error: errorStatus=2, errorIndex=1
 
d:\server1>snmputil get localhost public .1.3.6.1.4.1.232.18.2.3.1.1.34.2 
Variable = .iso.org.dod.internet.private.enterprises.232.18.2.3.1.1.34.2
Value = Integer32 2

For any NIC that returns a value of 2 we then need to check the speed of that interface with the following command;

 
d:\server1>snmputil get localhost public .1.3.6.1.4.1.232.18.2.3.1.1.33.2 
Variable = .iso.org.dod.internet.private.enterprises.232.18.2.3.1.1.33.2
Value = Integer32 1000000000

So in this case we had a NIC (.2) that is set auto but is running gig which is good. We need to identify any NIC running auto not running gig, so if the NIC (.2) was running 10mps it would look like this;

 
d:\server1>snmputil get localhost public .1.3.6.1.4.1.232.18.2.3.1.1.33.2 
Variable = .iso.org.dod.internet.private.enterprises.232.18.2.3.1.1.33.2
Value = Integer32 10000000

How do I write this into a script? Any ideas?

Shell script ?

---------- Post updated at 11:20 ---------- Previous update was at 11:02 ----------

With bash, you can try something like that (not tested) :

adr=.1.3.6.1.4.1.232.18.2.3.1.1
adr34=${adr}.34
adr33=${adr}.33

for ((i=1; i<=256; i++))
do

   value=$(snmputil get localhost public ${adr34}.$i | awk '/Value/ {print $3}')
   if [ "${value}" = "2" ]
   then
      value=$(snmputil get localhost public ${adr33}.$i | awk '/Value/ {print $3}')
      if [ "${value}" != "1000000000" ]
      then
         echo "NIC $i not running gig (${value})"
      fi
   fi
done
exit

Jean-Pierre.

look at FOR in dos batch scripting
for /L %%a in (1,1,10) do ( <--- Something similar
and then look at findstr in batch ... to get pure dos batch file

Other ways download GNU bash for windows or busybox etc ... and it will be easier ..

Thank you so much Aigles and Chakrapani for the ideas.

If you can pull what you need from WMI, then you can write a loop in powershell or vbscript to get the info you need from one box.