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?

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)

?

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:)

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

Also check this code snippet http://www.daniweb.com/code/snippet257449.html if you want the output, error and return status of your command.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.