Putty の実行バッチ

毎朝(と言うほどでもないが)Windowsマシンから、その辺のいくつもの Linux系マシンに ssh接続(Putty) してるわけだが、特定の複数のマシンへの接続なんだからバッチファイルで一個実行すれば全部開くように出来ないかなと。
Puttyのユーザーマニュアルによると、コマンドラインからの実行でなんとかなりそう、-loadオプションで、ストアされた(保存された)セッションも起動できる。遠隔マシンによって文字コードが違ったり(最近インストールしたのは UTF8、まえのは EUC_JP とか)するのでこれは嬉しい。
ただし、「.bat」バッチファイルだと、その行の実行の終了は Putty 端末の終了になるので、沢山いっぺんに開くとかは出来ない。そういうときは、WScript.Shell の Runメソッドの第3引数を false にする。ActiveScriptRuby でこんな感じ。第2引数の 1 は、普通のウィンドウで開くことの指定。

require 'win32ole'
wsh = WIN32OLE.new 'WScript.Shell'
wsh.Run '"C:\Program Files\PuTTY\puttyjp.exe" -load "<セッション名>"', 1, false
wsh.Run '"C:\Program Files\PuTTY\puttyjp.exe" -load "My Defaults" <ユーザ名>@<ホスト名>', 1, false
 ……

Puttyのユーザマニュアルより、コマンドラインオプションのリストは下記

Section 3.8.3.1: -load: load a saved session
Section 3.8.3.2: Selecting a protocol: -ssh, -telnet, -rlogin, -raw
Section 3.8.3.3: -v: increase verbosity
Section 3.8.3.4: -l: specify a login name
Section 3.8.3.5: -L, -R and -D: set up port forwardings
Section 3.8.3.6: -m: read a remote command or script from a file
Section 3.8.3.7: -P: specify a port number
Section 3.8.3.8: -pw: specify a password
Section 3.8.3.9: -agent and -noagent: control use of Pageant for authentication
Section 3.8.3.10: -A and -a: control agent forwarding
Section 3.8.3.11: -X and -x: control X11 forwarding
Section 3.8.3.12: -t and -T: control pseudo-terminal allocation
Section 3.8.3.13: -N: suppress starting a shell or command
Section 3.8.3.14: -nc: make a remote network connection in place of a remote shell or command
Section 3.8.3.15: -C: enable compression
Section 3.8.3.16: -1 and -2: specify an SSH protocol version
Section 3.8.3.17: -4 and -6: specify an Internet protocol version
Section 3.8.3.18: -i: specify an SSH private key
Section 3.8.3.19: -pgpfp: display PGP key fingerprints