hi all


can u pls help me regarding iterating through an integer variable within a subprocess call


here is what i exactly want to do
for n in range(1,16):
subprocess.call()
i.e.,
i want to iterate through snmpwalk..but its not working:(


it shows 'bad value name n'

pls help me out
thanks in advance

I don't know the command snmpset, but the 'n' in your call should probably be n (without quotes). Also the '-c arct1c' should be split in '-c', 'arct1c'.

Do you actually mean n (wihtout '') or str(n) in your code?

thanks for the replies...the n in my code shoul be substituted with 1,2 3,.......upto 15

thanks for the replies...the n in my code shoul be substituted with 1,2 3,.......upto 15

Did you try

for n in range(1,16):
    subprocess.call(
        'snmpset -v2c -c arct1c 192.168.5.157 .1.3.6.1.4.1.18489.1.2.1.5.1.2.0 i %d' % n,
        shell = True)

?

Edited 6 Years Ago by Gribouillis: n/a

Did you try

for n in range(1,16):
    subprocess.call(
        'snmpset -v2c -c arct1c 192.168.5.157 .1.3.6.1.4.1.18489.1.2.1.5.1.2.0 i %d' % n,
        shell = True)

?

3 cheers:) thnx a lot Gribouillis..it's working:)

This question has already been answered. Start a new discussion instead.