TERA TERMのLOGの取得方法を教えてください。


障害機器のLOGの取得のため長期にLOGを取得する必要があるのですが、自動で日付ごとにLOGファイルを更新してくれる方法等がありますでしょうか。

回答の条件
  • URL必須
  • 1人2回まで
  • 登録:
  • 終了:2009/11/17 12:35:02
※ 有料アンケート・ポイント付き質問機能は2023年2月28日に終了しました。

ベストアンサー

id:makeworld No.3

回答回数75ベストアンサー獲得回数23

ポイント10pt

Tera Termマクロで、logcloseとlogopenを繰り返せばOKだと思います。

こんな感じでしょうか。

  • rotate-log.ttl
;; ログの置き場所
strLogPath = 'C:\LOG\'

;; ログファイル名の先頭につける文字列
strPrefix = 'teraterm-'

;; ログファイルの拡張子
strExtension = '.log'

;; ログファイルオプション
;; bLogBinary (0: テキスト, 0以外: バイナリ)
bLogBinary = 0
;; bLogAppend (0: 上書き, 0以外: 追記)
bLogAppend = 1

;; 現在のログファイル名
strCurLogfile = ''

;; メインループ
:mainloop

;; 日付の取得
getdate strDate
strcopy strDate 1 4 strYear
strcopy strDate 6 2 strMonth
strcopy strDate 9 2 strDay

;; 時刻の取得
gettime strTime
strcopy strTime 1 2 strHour
strcopy strTime 4 2 strMinute
strcopy strTime 7 2 strSecond

;; ログファイル名を生成
strLogfile = strLogPath
strconcat strLogfile strPrefix
strconcat strLogfile strYear
strconcat strLogfile '-'
strconcat strLogfile strMonth
strconcat strLogfile strDay
;strconcat strLogfile '-'
;strconcat strLogfile strHour
;strconcat strLogfile strMinute
;strconcat strLogfile strSecond
strconcat strLogfile strExtension

;; ログファイル名が同じなら、待ち
strcompare strCurLogfile strLogfile
if result = 0 goto waitandnext

;; ログを開始
logclose
strCurLogfile = strLogfile
logopen strCurLogfile bLogBinary bLogAppend

;; 一定時間何もしない
:waitandnext
pause 60

goto mainloop

なーした日記: 続・TeraTermのマクロ

その他の回答2件)

id:gday No.1

回答回数383ベストアンサー獲得回数71

ポイント35pt

TeraTerm でのログ自動取得方法

http://d.hatena.ne.jp/KuroNeko666/20090721/1248154317

id:b-wind No.2

回答回数3344ベストアンサー獲得回数440

ポイント35pt

最新のTeraTermをいじってみて驚いた - u-ichiのにっき

設定ファイルに以下の内容を記述すれば可能。

LogHideDialog=on
LogDefaultName=teraterm%y%m%d.log
LogAutoStart=on

細かい部分はお好みで修正してください。

id:makeworld No.3

回答回数75ベストアンサー獲得回数23ここでベストアンサー

ポイント10pt

Tera Termマクロで、logcloseとlogopenを繰り返せばOKだと思います。

こんな感じでしょうか。

  • rotate-log.ttl
;; ログの置き場所
strLogPath = 'C:\LOG\'

;; ログファイル名の先頭につける文字列
strPrefix = 'teraterm-'

;; ログファイルの拡張子
strExtension = '.log'

;; ログファイルオプション
;; bLogBinary (0: テキスト, 0以外: バイナリ)
bLogBinary = 0
;; bLogAppend (0: 上書き, 0以外: 追記)
bLogAppend = 1

;; 現在のログファイル名
strCurLogfile = ''

;; メインループ
:mainloop

;; 日付の取得
getdate strDate
strcopy strDate 1 4 strYear
strcopy strDate 6 2 strMonth
strcopy strDate 9 2 strDay

;; 時刻の取得
gettime strTime
strcopy strTime 1 2 strHour
strcopy strTime 4 2 strMinute
strcopy strTime 7 2 strSecond

;; ログファイル名を生成
strLogfile = strLogPath
strconcat strLogfile strPrefix
strconcat strLogfile strYear
strconcat strLogfile '-'
strconcat strLogfile strMonth
strconcat strLogfile strDay
;strconcat strLogfile '-'
;strconcat strLogfile strHour
;strconcat strLogfile strMinute
;strconcat strLogfile strSecond
strconcat strLogfile strExtension

;; ログファイル名が同じなら、待ち
strcompare strCurLogfile strLogfile
if result = 0 goto waitandnext

;; ログを開始
logclose
strCurLogfile = strLogfile
logopen strCurLogfile bLogBinary bLogAppend

;; 一定時間何もしない
:waitandnext
pause 60

goto mainloop

なーした日記: 続・TeraTermのマクロ

  • id:KuroNeko666
    日付を srtf に置き換えて、Ver 6.42 以降対応としてみた。
    --------------------------------------------------------
    ;; TeraTerm Ver 4.62 以降で利用可能(最新版を推奨)

    ;; ログの置き場所
    strLogPath = 'C:\LOG\'

    ;; ログファイルオプション
    ;; bLogBinary (0: テキスト, 0以外: バイナリ)
    bLogBinary = 0
    ;; bLogAppend (0: 上書き, 0以外: 追記)
    bLogAppend = 1

    ;; 現在のログファイル名
    strCurLogfile = ''

    ;; メインループ
    :mainloop

    ;; ログファイル名の生成(strf)
    ;getdate strLogfile "teraterm-%Y-%m%d-%H%M%S.log"
    getdate strLogfile "teraterm-%Y-%m%d.log"

    ;; ログファイル名が同じなら、待ち
    strcompare strCurLogfile strLogfile
    if result != 0 goto error

    ;; ログを開始
    logclose
    strCurLogfile = strLogfile
    logopen strCurLogfile bLogBinary bLogAppend
    if result = 0 goto waitandnext

    ;; 一定時間何もしない
    :waitandnext
    pause 60

    goto mainloop

    :error
    messagebox 'Log open error' 'Error message'

この質問への反応(ブックマークコメント)

「あの人に答えてほしい」「この質問はあの人が答えられそう」というときに、回答リクエストを送ってみてましょう。

これ以上回答リクエストを送信することはできません。制限について

回答リクエストを送信したユーザーはいません