def cat_script(self, e):
#opens an ssh pipe and runs a cat command to get the text of the script
target_ip = pi_link_pnl.target_ip
target_user = pi_link_pnl.target_user
target_pass = pi_link_pnl.target_pass
script_path = self.cron_path_combo.GetValue()
script_name = self.cron_script_cb.GetValue()
script_to_ask = script_path + script_name
try:
# ssh.connect(target_ip, username=target_user, password=target_pass, timeout=3)
print "Connected to " + target_ip
print("running; cat " + str(script_to_ask))
stdin, stdout, stderr = ssh.exec_command("cat " + str(script_to_ask))
script_text = stdout.read().strip()
error_text = stderr.read().strip()
if not error_text == '':
msg_text = 'Error reading script \n\n'
msg_text += str(error_text)
else:
msg_text = script_to_ask + '\n\n'
msg_text += str(script_text)
wx.MessageBox(msg_text, 'Info', wx.OK | wx.ICON_INFORMATION)
except Exception as e:
print("oh bother, this seems wrong... " + str(e))
评论列表
文章目录