マクロの作成を行ってみたいと思います。
☆マクロ作成
①teratermフォルダ配下(私の場合はC:\Program Files\teratermです)にテキストファイルを新規で作成し<xxx.ttl>にファイル名を変更する
※<xxx.ttl>はxxxにてきとうな名前をつけてあげてください。(私はworklog.ttlにしました)
②テキストエディタで<xxx.ttl>を開く
まずはログインのマクロですがサンプルのssh2login.ttlがそれに当たりますのでそのまま拝借します
③サンプルから拝借したものを編集します
まずサンプルのままだと
username = 'nike'
hostname = '192.168.1.3'
となっているのでここの'nike'の部分をサーバのユーザ名
'192.168.1.3'の部分をサーバのIPアドレス or HOSTNAMEに変更します
④上書き保存をし試しに実行してみます
パスワードを入力し
ログイン成功(´・ω・`)
ログイン部分はssh2login.ttlほぼそのままでいけそうなので
続いてログ自動取得の部分を組み込んでみます
以下今回作成したコード
***********************************************************************
;変数宣言
strHostname = '<サーバホスト名>'
strFilepath = '<ログ作成ファイルパス>'
username = '<サーバユーザ名>'
hostname = '<サーバIPアドレス>'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;ログ名称作成
getdate strDate
strcopy strDate 1 4 YYYY
strcopy strDate 6 2 MM
strcopy strDate 9 2 DD
strconcat strFilepath YYYY
strconcat strFilepath MM
strconcat strFilepath DD
strconcat strFilepath '_'
strconcat strFilepath strHostname
strconcat strFilepath '.log'
;ログイン
msg = 'Enter password for user '
strconcat msg username
passwordbox msg 'Get password'
msg = hostname
strconcat msg ':22 /ssh /auth=password /user='
strconcat msg username
strconcat msg ' /passwd='
strconcat msg inputstr
connect msg
logopen strFilepath 0 1
sendln ''
************************************************************************
動作確認はOKでした。
ログ名称は<日付>_<ホスト名>.logで作成されます。
これでわずらわしい操作から開放されて作業できる(´・ω・`)
0 件のコメント:
コメントを投稿