2013-07-11 25 views
5

我想遠程登錄到我的路由器,並且我想將其自動化,所以我不必一直登錄,因爲我一天都會多次登錄。如何在不使用SendKeys的情況下自動化Telnet會話

除了VBS中的sendkeys,還有其他的方法嗎?這是因爲物理類型,所以telnet窗口需要激活,而且很煩人。

我嘗試了一個批處理文件,但我得到了非常奇怪的結果。那就是:

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! 

下面是結果:

C:\Users\George\Desktop>telnet 192.168.1.254 

C:\Users\George\Desktop>telnet 192.168.1.254 
^C Terminate batch job (Y/N)? 

爲什麼這樣做呢?這將是我的預期結果...

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]=> 

那麼,它爲什麼這樣做呢?

我可以使用sendkeys之外的其他方法嗎?

+0

你想到的是一個'平255.255.255.255 -n 1 -w 1000> nul'由cmd.exe的執行,但'george'應該被髮送到Telnet客戶端? cmd.exe應該如何知道您的期望? – jeb

+0

哦 - 我使用ping來創建延遲,因爲它需要一些時間來連接。這就是爲什麼我得到一個無限循環? – George

回答

5

您可以谷歌這個工具:它沒有腳本窗口TELNET.EXE,但它是一個腳本的telnet客戶。

Telnet Scripting Tool v.1.0
阿爾伯特耶魯

+1

謝謝 - 我發現它[這裏](http://support.moonpoint.com/downloads/windows/network/Telnet/tst10.php)作爲openDNS返回一個錯誤與您給的鏈接 – George

相關問題