<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[在secureCRT软件上运行一些简单的python脚本]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Unix/LinuxC技术]]></category>
<pubDate>Thu, 03 Jan 2019 05:56:54 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	背影：买了个Mac本，无法用.vbs脚本,输入个密码啥的更快一些。<br/>xiangdongAutoEnterPasswd*.py<br/><textarea name="code" class="php" rows="15" cols="100">
# $language = &quot;python&quot;
# $interface = &quot;1.0&quot;

# This script demonstrates how to open a text file and read it line by
# line to a server.


def main():
&nbsp;&nbsp;crt.Screen.Synchronous = True
&nbsp;&nbsp;# Note: A IOError exception will be generated if &#039;input.txt&#039; doesn&#039;t exist.
&nbsp;&nbsp;#
&nbsp;&nbsp;for line in open(&quot;/Users/jackXiang/secureCRT/script/temp/input.txt&quot;, &quot;r&quot;):
&nbsp;&nbsp;&nbsp;&nbsp;# Send the line with an appended CR
&nbsp;&nbsp;&nbsp;&nbsp;#
&nbsp;&nbsp;&nbsp;&nbsp;crt.Screen.Send(line + &#039;&#92;r&#039;)
&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;# Wait for my prompt before sending the next line
&nbsp;&nbsp;&nbsp;&nbsp;#
&nbsp;&nbsp;&nbsp;&nbsp;crt.Screen.WaitForString(&quot;prompt$&quot;)

&nbsp;&nbsp;crt.Screen.Synchronous = False

&nbsp;&nbsp;
main()
</textarea><br/><br/>secureCRT支持运行.js和.vbs以及.py格式的脚本，无奈mac上识别前两个格式的脚本只能写一写python脚本， <br/>举个简单的例子，利用脚本直接ssh连接一台机器， <br/>在View菜单中勾选Button Bar让这个菜单在下方显示出来， <br/>在下方的Default右方右键出现一个菜单点击New Button按钮，在显示框的Function一栏选择Run Script中间选择编写好的.py文件 <br/>.py文件的内容大致如下：<br/><textarea name="code" class="php" rows="15" cols="100">
# $language = &quot;python&quot;
# $interface = &quot;1.0&quot;

#官方的实例可以在未连接任何服务器的情况下进行ssh连接

#你要连接的ssh服务器ip
host = &#039;139.196.53.1**&#039;
#ssh用户名
user = &#039;root&#039;
#ssh密码
passwd = &#039;Jinx0007&#039;

def main():

&nbsp;&nbsp;&nbsp;&nbsp;#进行cmd操作连接创建新的session连接
&nbsp;&nbsp;&nbsp;&nbsp;cmd = &quot;/SSH2 /L %s /PASSWORD %s /C 3DES /M MD5 %s&quot; % (user, passwd, host)
&nbsp;&nbsp;&nbsp;&nbsp;crt.Session.Connect(cmd)
&nbsp;&nbsp;&nbsp;&nbsp;#使用默认弹窗提示信息
&nbsp;&nbsp;&nbsp;&nbsp;crt.Dialog.MessageBox(&#039;登录成功!&#039;)

main()
</textarea><br/><br/>另外一个：<br/><textarea name="code" class="php" rows="15" cols="100">
# $language = &quot;python&quot;
# $interface = &quot;1.0&quot;
#此方法表示你必须先登录一台ssh服务器然后再去ssh到另外一台服务器
#ssh主机的ip
host = &#039;192.168.0.111&#039;
#ssh主机的用户名
user = &#039;root&#039;
#ssh主机的密码
passwd = &#039;Jinx0007&#039;

def main():
&nbsp;&nbsp;&nbsp;&nbsp;#向屏幕光标后发送以下文字内容，&#92;r表示回车执行
&nbsp;&nbsp;&nbsp;&nbsp;crt.Screen.Send(&#039;ssh &#039;+user+&#039;@&#039;+host+&#039;&nbsp;&nbsp;&#92;r&#039;)
&nbsp;&nbsp;&nbsp;&nbsp;#在5秒内等待屏幕出现password:或者yes/no文字进行下方操作，超过5秒表示超时
&nbsp;&nbsp;&nbsp;&nbsp;result = crt.Screen.WaitForStrings([&#039;password:&#039;,&#039;(yes/no)&#039;],5)
&nbsp;&nbsp;&nbsp;&nbsp;#当屏幕出现password:字符
&nbsp;&nbsp;&nbsp;&nbsp;if result == 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;crt.Screen.Send(passwd+&quot;&#92;r&quot;)
&nbsp;&nbsp;&nbsp;&nbsp;#屏幕出现(yes/no)等相关字符
&nbsp;&nbsp;&nbsp;&nbsp;if result == 2:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;crt.Screen.Send(&#039;yes &#92;r&#039;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;crt.Screen.WaitForString(&#039;password:&#039;, 2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;crt.Screen.Send(passwd+&quot;&#92;r&quot;)
&nbsp;&nbsp;&nbsp;&nbsp;#等待屏幕出现&#039;]$&#039;字符
&nbsp;&nbsp;&nbsp;&nbsp;crt.Screen.WaitForString(&#039;]$&#039;,5)
&nbsp;&nbsp;&nbsp;&nbsp;#使用默认弹窗提示信息
&nbsp;&nbsp;&nbsp;&nbsp;crt.Dialog.MessageBox(&#039;登录成功!&#039;)

main()
</textarea><br/><br/>来自：https://blog.csdn.net/medivhq/article/details/52119572
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] 在secureCRT软件上运行一些简单的python脚本]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>