recvfile

受信データをファイルに出力する。 (バージョン 5.6.0以降)

recvfile <filename> <binary flag> <Auto-stop wait time>

解説

ホストから受信したデータを <filename> で指定されたファイルに出力する。
データ受信が終わるまで次のコマンドは実行されない。

<filename> が相対パスの場合は、ファイル転送用ディレクトリ相対として扱う。

<binary flag> の値(数値)が何であれ、受信したデータをそのままファイルに出力する。
漢字コード、改行文字の変換、制御文字の出力抑止等は行わない。(バイナリモード固定)

<Auto-stop wait time> で指定した秒数の間、受信データが無い状態が続いた場合にデータ受信を終了する。
この場合、システム変数 result に1が格納される。それ以外の場合、 result に0が格納される。
<Auto-stop wait time> の単位は秒、0以下の値を指定した場合はデータ受信を終了せず、データを待ち続ける。

; Connect to the remote host
connect '192.168.0.10:22 /ssh /user=root /passwd=XXXXXX /auth=password'

; Wait for the shell prompt
waitregex '.*[$#] '

; Wait 3 seconds to allow recvfile to start
; Save stty settings to "save_stty"
; Run "stty raw" so that the remote host sends the output data exactly as-is, without any modification
; Print /var/log/messages to stdout
; Restore stty settings
; Wait 5 seconds to signal the end of transmission
sendln 'sleep 3; save_stty=$(stty -g); stty raw; cat /var/log/messages; stty "${save_stty}"; sleep 5'

; Wait 1 second for sendln to complete
pause 1

; Save received data to C:\tmp\messages
; Exit recvfile if no data is received for 3 seconds
recvfile 'C:\tmp\messages' 1 3

; Wait for the shell prompt
waitregex '.*[$#] '

; Log out from the remote host
sendln 'exit'

; Close Tera Term
closett

; End macro execution
end

参照