我尝试在securecrt中为juniper路由器运行python脚本,比如我在上面显示配置,然后对其中的字符串进行更改/替换,我想获取show配置的输出,然后将其放入列表,然后进行更改,然后将其更改为字符串,然后应用它。你知道吗
示例如下:
#set policy-options policy-statement STM64-L1 term ARI from route-filter 1.1.1.1/32 exact
#set policy-options policy-statement STM64-L1 term ARI then accept
#set policy-options policy-statement STM64-L1 term rej then reject
在这里,我想用10G-L100替换字符串STM64-L1,然后将配置再次作为字符串应用到路由器
我的代码如下:
crt.Screen.Synchronous = True
JGR= crt.Dialog.Prompt("enter term name that will applied: ")
rep= crt.Dialog.Prompt("enter term name that will removed ")
pol= crt.Dialog.Prompt("enter policy that will remove term from it ")
npt= crt.Dialog.Prompt("enter policy that will add term to it ")
crt.Screen.Send("show configuration | display set | match " +JGR+ "\n")
crt.Screen.WaitForString("/n")
x=crt.Screen.ReadString("exact")
x.split(",")
term_name=x
term_name=list()
for word in term_name:
h=term_name.index(pol)
term_name.pop(h)
term_name.insert(h,npt)
yyy= ' '.join(term_name)
crt.Screen.Send("edit private "+ "\n")
crt.Screen.WaitForString("router#")
crt.Screen.Send(yyy+ "\n")
crt.Screen.WaitForString("router#")
crt.Screen.Send("show | compare " + "\n")
crt.Screen.Synchronous = False
主()
但我面临的问题是,脚本运行时没有错误,但没有应用任何配置,比如yyy的值只是空间?你知道吗
谢谢
目前没有回答
相关问题 更多 >
编程相关推荐