teratermマクロでSCPを使用してファイルを送受信

teratermマクロでSCP(Secure Copy Protcol)を使用してlinuxサーバからローカルPCにファイルを転送します。
うまくやれば定期的にログの収集等を自動的にやってくれるように作成できます。
尚、逆にローカルPCからサーバにファイルを転送する場合は‘scpsend’を使用します。

scprecv.ttl

;192.168.0.1にSSH接続。ユーザ名とパスワードは各自の環境に修正
connect ‘192.168.0.1:22 /ssh /2 /auth=password /user=root /passwd=password’

;rootユーザの場合は’#’に変更する
wait ‘$’

;ファイルコピー元のファイル名と、コピー先でのファイル名を指定(絶対パス推奨)
;’/home/hoge/test.log’を’c:\test.log’に転送するよう指定してます。

scprecv ‘/home/hoge/test.log’ ‘c:\test.log’

以下はこのマクロを使用して気づいた点です。改善・回避できる方法があれば教えて下さい…。
・2GBを超えるファイルを扱うことができない
・受信先に指定したディレクトリに同じファイル名がある場合はできない
・最初の”connect”コマンドで指定したsshユーザでファイルを送信する。
 その為、例えば一般ユーザでssh接続だと/var/log/配下のログを送信できない。(パーミッション制限の為)
・最後に’exit’を入れると、ファイル転送中にも関わらず中断・終了してしまう。’if result 0’等しても中断してしまうんだけど…。どうにかならんの?

シェアする

  • このエントリーをはてなブックマークに追加

フォローする

コメント

  1. Have you considered adding several social bookmarking buttons to these blogs. At least for flickr.

  2. I needed to say that it is great to know that somebody mentioned this as I had problems discovering the identical information elsewhere. This was the first place that gave me the information. Thanks.

  3. What’s Taking place i’m new to this, I stumbled upon this I’ve discovered It positively useful and it has helped me out loads. I am hoping to contribute & aid other users like its helped me. Good job.

  4. Very effectively written information. Will probably be valuable to anybody who usess it, including myself. Sustain the nice work – for sure i will try extra posts.