Do anyone know to to just print the string after query from mib?
After running the script will show "Test:SNMPv2-SMI::mib-2.69.1.4.5.0 = STRING: "test.cfg"", how to left out with just "test.cfg"
i used this way:
i saw the problem to my code, one have double quote " ", another one have no quote
"test.cfg"
test.cfg
any way to remove the " "
After running the script will show "Test:SNMPv2-SMI::mib-2.69.1.4.5.0 = STRING: "test.cfg"", how to left out with just "test.cfg"
import os direct_output = os.popen('snmpwalk -cpublic -v 2c 172.16.25.42 1.3.6.1.2.1.69.1.4.5.0 ').read() print("File Name:"+direct_output) #output: Test:SNMPv2-SMI::mib-2.69.1.4.5.0 = STRING: "test.cfg" if direct_output =="test.cfg": print('Same File name') print("end script')
i used this way:
import os direct_output = os.popen('snmpwalk -cpublic -v 2c 172.16.25.42 1.3.6.1.2.1.69.1.4.5.0 ').read() #print("Test:"+direct_output) test123=direct_output.replace('SNMPv2-SMI::mib-2.69.1.4.5.0 = STRING: ','') print(test123) if test123 == "test.cfg": print("same") else: print("end")but it didn't print same, do anyon know why
i saw the problem to my code, one have double quote " ", another one have no quote
"test.cfg"
test.cfg
any way to remove the " "