问题描述
我被困在这里一个多小时,但似乎无法找到我的问题的解决方案。问题是我无法完全匹配字符串输出。
实际输出:
hostname#$192.168.1.1/out/c2960x-universalk9-mz.152-7.E3.bin flash:c2960x-universalk9-mz.152-7.E3.bin
Destination filename [c2960x-universalk9-mz.152-7.E3.bin]?
我的代码不起作用:
commandsend = "copy ftp://206.112.194.143/out/c2960x-universalk9-mz.152-7.E3.bin flash:c2960x-universalk9-mz.152-7.E3.bin"
output = connection.send_command(commandsend,expect_string=r'Destination filename')
output += connection.send_command('\n',expect_string=r'#')
复制ftp://x.x.x.x/out/c2960x-universalk9-mz.152-7.E3.bin flash:c2960x-universalk9-mz.152-7.E3.bin 21:11:27.067 GMT 2021 年 5 月 12 日星期三 回溯(最近一次调用最后一次): 文件“./svu.py”,第 292 行,在 output = uploading_update(models,ver[0],ver[1],ver[2],ver[3]) # 发送到 func {'CSR1000V': ['12.2.55',文件“./svu.py”,第 119 行,在 uploading_update 中 output = connection.send_command(commandsend,expect_string=r'目标文件名') 文件“/home/repos/public/Python/lib/python3.6/site-packages/netmiko/base_connection.py”,第 1112 行,在 send_command search_pattern)) OSError:send_command_expect 中从未检测到搜索模式:目标文件名
我尝试使用以下方法,但仍然无效
output = connection.send_command(commandsend,expect_string=r'Destination.*')
output = connection.send_command(commandsend,expect_string='Destination.*')
output = connection.send_command(commandsend,expect_string=r'Destination filename.+')
我什至尝试调整延迟因子和 fast_cli=False 但还是一样。
output = connection.send_command(commandsend,expect_string=r'Destination filename [c2960x-universalk9-mz.152-7.E3.bin]? ')
位置 27 处的错误字符范围 x-u
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)