我正在尝试跟踪日志文件,并且它有效。但我还需要能够分析输出并记录错误等。我正在使用 Paramiko-expect github 页面上的基本示例,但我不知道如何执行此操作。
import traceback
import paramiko
from paramikoe import SSHClientInteraction
def main():
# Set login credentials and the server prompt
hostname = 'server'
username = 'username'
password = 'xxxxxxxx'
port = 22
# Use SSH client to login
try:
# Create a new SSH client object
client = paramiko.SSHClient()
# Set SSH key parameters to auto accept unknown hosts
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# Connect to the host
client.connect(hostname, port, username, password)
# Create a client interaction class which will interact …Run Code Online (Sandbox Code Playgroud) 原始问题:
我的表单正确地验证了验证,但是在不应该的时候提交.
关注http://formvalidation.io/examples/ajax-submit/
查看我的控制台我没有看到.on"错误"部分中的任何日志语句或打印出的"成功".页面只是发布到自己.随着网址中的数据.我不知道我在这里缺少什么,因为它基本上会跳过所有.on陈述.
这里发生了什么?
请记住,验证仅适用于.on语句.
HTML:
<form id="service_path_form" class="form-horizontal">
<div class="form-group">
<label class="col-xs-3 control-label">Service Name</label>
<div class="col-xs-8">
<input type="text" class="form-control" name="service_path_name" placeholder="Name" />
</div>
</div>
<div class="form-group">
<label class="col-xs-3 control-label">IP</label>
<div class="col-xs-5">
<input type="text" class="form-control" name="service_path_ip" placeholder="IP" />
</div>
</div>
<div class="form-group">
<label class="col-xs-3 control-label">Description</label>
<div class="col-xs-8">
<textarea class="form-control" name="service_path_description" rows="3" placeholder="Write a short Description"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-xs-3 control-label">Enable</label>
<div class="col-xs-5">
<div class="radio">
<label>
<input type="radio" name="service_path_enabled" value="1" /> …Run Code Online (Sandbox Code Playgroud) 我从 Python 脚本中得到一个奇怪的输出
当在循环中运行代码以进行涉及 Paramiko 的实际执行时,它似乎颠倒了要打印的变量的顺序,同时覆盖了输出的开始。
要处理的所有源文本对于两者都是相同的。一个是通过 Paramiko 通过 ssh 从路由器抓取的,另一个是我手动抓取并粘贴为局部变量。
电流输出:
with testis 10.8.11.72 from 10.8.11.72 (10.111.72.1)
Run Code Online (Sandbox Code Playgroud)
具有静态局部变量的所需输出和输出:
Best Path is 10.8.11.73 from 10.8.11.73 (10.111.73.1) with localpref 120
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会这样。请参阅下文了解更多信息和执行。帮助?
代码:
import paramiko
router_channel.send('sh ip bgp 10.23.24.32\n')
buff = ''
best_test =()
while not buff.endswith('#'):
resp = router_channel.recv(99999)
buff += resp
#DMVPN variable Declaration.
bgp_show = buff
bgp_list = bgp_show.split('Local')
bgp_list.pop(0)
for x in bgp_list:
if 'best' in x:
best_list = x.split('\n')
for x in best_list:
best_list = [x.strip(' …Run Code Online (Sandbox Code Playgroud)