windows 如何在没有 SendKeys 的情况下自动执行 Telnet 会话
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17601579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How To Automate A Telnet Session Without SendKeys
提问by George
I would like to telnet into my router, and I want to automate it so I do not have to login all the time, as I do it several times a day.
我想通过 telnet 登录我的路由器,并且我想将它自动化,这样我就不必一直登录,因为我每天都要登录几次。
Is there another method apart from sendkeys in VBS? This is because that physically types, so the telnet window needs to be active, with is rather annoying.
除了 VBS 中的 sendkeys 之外,还有其他方法吗?这是因为物理类型,所以telnet窗口需要处于活动状态,比较烦人。
I tried a batch file, but I am getting really strange results. Here it is:
我尝试了一个批处理文件,但得到了非常奇怪的结果。这里是:
telnet 192.168.1.254
REM This is the router IP
ping 255.255.255.255 -n 1 -w 1000 > nul
REM This is to wait for the router if its being slow
George
REM This is the username, as it prompts as soon as it logs in
ping 255.255.255.255 -n 1 -w 1000 > nul
(the password)
ping 255.255.255.255 -n 1 -w 1000 > nul
system
REM Enters the system menu
ping 255.255.255.255 -n 1 -w 10 > nul
debug
REM Enters the Debug menu
ping 255.255.255.255 -n 1 -w 100 > nul
:s
cpu
REM This lets me see the CPU usage
ping 255.255.255.255 -n 1 -w 1000 > nul
REM Wait while it lists it
mem
REM Checks the memory
ping 255.255.255.255 -n 1 -w 1000 > nul
REM Waits again!
goto s
REM I need a loop otherwise I would have to type out lots of code!
Here are the results:
结果如下:
C:\Users\George\Desktop>telnet 192.168.1.254
C:\Users\George\Desktop>telnet 192.168.1.254
^C Terminate batch job (Y/N)?
Why is it doing this? This would be my expected result...
为什么要这样做?这将是我预期的结果......
Username : George
Password : *******
------------------------------------------------------------------------
______ Technicolor TG582n
___/_____/\
/ /\ 8.C.M.0.AR
_____/__ / \
_/ /\_____/___ \ Copyright (c) 1999-2012, Technicolor
// / \ /\ \
_______//_______/ \ / _\/______
/ / \ \ / / / /\
__/ / \ \ / / / / _\__
/ / / \_______\/ / / / / /\
/_/______/___________________/ /________/ /___/ \
\ \ \ ___________ \ \ \ \ \ /
\_\ \ / /\ \ \ \ \___\/
\ \/ / \ \ \ \ /
\_____/ / \ \ \________\/
/__________/ \ \ /
\ _____ \ /_____\/
\ / /\ \ /___\/
/____/ \ \ /
\ \ /___\/
\____\/
------------------------------------------------------------------------
{George}=>system
{George}=>debug
{George}[system debug]=>cpu
CPU (%): Idle User Kernel
57.43 0.99 41.58
{George}[system debug]=>mem
Total: 61280 KB
Used: 45216 KB
by kernel: 30748 KB
by applications: 14468 KB
{George}[system debug]=>
So, Why is it doing this?
那么,它为什么要这样做呢?
Can I use another method apart from sendkeys?
除了 sendkeys 之外,我可以使用其他方法吗?
采纳答案by foxidrive
You can google for this tool: it doesn't script windows telnet.exe but it is a scriptable telnet client.
您可以在 google 上搜索此工具:它不会编写 windows telnet.exe 脚本,但它是一个可编写脚本的 telnet 客户端。
Telnet Scripting Tool v.1.0
by Albert Yale
Telnet 脚本工具 v.1.0
by Albert Yale
回答by Enim
Telnet Scripting tool (TST10) is old but yet very efficient,
here is a modern alternative to it, with a nice GUI
AutoTelnet.
Telnet 脚本工具 ( TST10) 很旧但非常有效,
这里有一个现代的替代品,带有一个漂亮的 GUI
AutoTelnet。
回答by npocmaka
One way is to use some of windows versions of netcat.Here'a an example: http://net.tutscity.com/networking/automate-telnet-session-using-netcat/
一种方法是使用一些 windows 版本的 netcat。这里有一个例子:http://net.tutscity.com/networking/automate-telnet-session-using-netcat/