Vote count:
0
I'm running a script on a network switch:
import exsh
def main():
#result='0'
#print result
result=exsh.clicmd('show ver', capture=True)
print result
result=exsh.clicmd('sh switch', capture=True)
print result
result=exsh.clicmd('sh vlan', capture=True)
print result
exsh.clicmd('create vlan vlan10 tag 10')
result=exsh.clicmd('sh vlan10', capture=True)
print result
exsh.clicmd=('del vlan10')
result=exsh.clicmd('sh vlan', capture=True)
print result
if True: main()
When I run it, I get the expected output until it gets to line 18:
Traceback (most recent call last):
File "/config/test.py", line 23, in <module>
if True: main()
File "/config/test.py", line 18, in main
result=exsh.clicmd('sh vlan', capture=True)
TypeError: 'str' object is not callable
What becomes even more unexpected is if I run it again immediately afterwards the error now occurs at line 8:
* X460-24p.2 # run script test.py
Traceback (most recent call last):
File "/config/test.py", line 23, in <module>
if True: main()
File "/config/test.py", line 8, in main
result=exsh.clicmd('show ver', capture=True)
TypeError: 'str' object is not callable
Not sure how to trace the problem.
asked 2 mins ago
1 Answer
Vote count:
0
Yo set exsh.clicmd=('del vlan10')
which makes exsh.clicmd
a string then you try to call it after with result=exsh.clicmd('sh vlan', capture=True)
answered 1 min ago
str object not callable on a script
Aucun commentaire:
Enregistrer un commentaire