Windows 最低限のTeraTermマクロの書き方

・コマンド一覧
http://www.macrosh.com/tera-termmakuronitsuite/komando-yi-lan

http://ttssh2.osdn.jp/manual/ja/macro/command/index.html?sess=67d7ca28bf4e708498e62eafc9c15730


・基本

1. connect - 接続先サーバを指定
2. wait    - 指定した文字列が返ってくるまで処理を止める
3. sendln  - 文字列を送信する

【例】サーバに接続して、ls を送信
connect 'server_name /ssh /auth=password /user=my_username /passwd=my_password'
wait '>'
sendln 'ls'

・変数に値を格納してコマンドを作成、接続

【例】
username = 'my_user'
password = 'my_password'
server =   'my_server'

cmd = server
strconcat cmd ' /ssh /auth=password'
strconcat cmd ' /user='
strconcat cmd username
strconcat cmd ' /passwd='
strconcat cmd password

connect cmd
wait '>'
sendln 'ls'

・username、password をファイルに格納して接続

【例】
server =     'my_server'
passwdfile = 'password.dat'

getpassword passwdfile 'username' username
getpassword passwdfile 'password' password

cmd = server
strconcat cmd ' /ssh /auth=password'
strconcat cmd ' /user='
strconcat cmd username
strconcat cmd ' /passwd='
strconcat cmd password

connect cmd
wait '>'
sendln 'ls'

※username と password が passwdfile に存在しない場合は対話式で値を入力する
※入力した username と password は暗号化されて passwdfile に保存される
※passwdfile はマクロファイルと同じフォルダに保存される