環境為 WINDOWS 2000 + SP4
有沒有什麼TELNET軟體可以設定或執行批次指令
要連線的平台像CISCO
希望能事先寫好設定檔, 然後可以帶參數, 用程式自動設定
剛剛有看到一些商業ssh元件可以用,只是我也沒嘗試。
http://www.djhd.com/ssh-activex-download.html
有.net跟activex的元件。可以試用30天。
有一段sample code,看起來應該可以做到你要的功能。
<pre class="c" name="code">
Ssh1.Blocking = True
Ssh1.Connect
Debug.Print Ssh1.WaitFor("joe@debian")
Ssh1.Prompt = "joe@debian"
Debug.Print Ssh1.Execute("cd /tmp" & vbLf)
Debug.Print Ssh1.Execute("ls -al" & vbLf)
execute方法還有一個參數讓你可以用字串或regular expression來檢查執行的結果。
試試看PuTTY Connection Manager
http://puttycm.free.fr/
這是一套based on PuTTY的免費程式.
如果你還沒裝Putty,可以到下列網址下載.
[
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html](<br />
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)
PuTTY 看來可以用 -m 的參數,執行本地端的指令稿(script)。底下的解說來自 PuTTY 官方網站文件:
3.8 The PuTTY command line
3.8.3.6 -m: read a remote command or script from a file
The -m option performs a similar function to the ‘Remote command’ box in the SSH panel of the PuTTY configuration box (see section 4.18.1). However, the -m option expects to be given a local file name, and it will read a command from that file.
With some servers (particularly Unix systems), you can even put multiple lines in this file and execute more than one command in sequence, or a whole shell script; but this is arguably an abuse, and cannot be expected to work on all servers. In particular, it is known not to work with certain ‘embedded’ servers, such as Cisco routers.
This option is not available in the file transfer tools PSCP and PSFTP.
不然,就在 MS Windows 2000 上面裝 cygwin 再裝 expect 吧,可以參考我的網誌:
網管的暗黑系法術:用 expect 和 autoexpect 寫 BBS 機器人,衝上站次數
TO powerop:
內容有提到, it is known not to work with certain ‘embedded’ servers, such as Cisco routers.
看起來是不能符合需求
cygwin加expect 的組合,光是環境的架設就有點複雜, 先不考慮了
謝謝回應
Hi aqr199,
那段話的意思,好像只是說,遇到像是 Cisco routers 這一類的系統,-m 後面接的文字檔裡面,可能無法放多行的指令。
不曉得如果只放一行,但是那一行其實是呼叫另一個指令稿(script),這樣行不行?
cygwin 其實可以用一指神功安裝耶,下載 http://www.cygwin.com/setup.exe 回來,然後一直按 next 就可以了。要記得在套件選擇的時候,多選 expect 喔,不然裝好了以後再重新執行這個 setup.exe 加選,也是可以的。