I have daily task to do in office. There are some log files which are created on web and app server using Java applications. I have to log in using PuTTY. Then I have to login to server (Web and App Server). I am using SSH. After that I have to go to a certain path. And then extract some logs file which are .txt files. And then after I have to go to command prompt in Windows and save the log files extracted by PuTTY to a local machine hard disk.

I want to automate the task of doing this. Is it possible to write procedure/script in PuTTY to do this task? Please point me to resources or any help will be appreciated.

  • 1
    You still didn't made the "login" step clear. There are two "login" steps? Note that you do NOT "login to PuTTY". You login "to the server". Do you then need to login anywhere further? Another server, not directly available from your Windows machine? Or some application? – Martin Prikryl Dec 19 '14 at 12:07

If I understand the question correctly, your Java apps write logs to regular text files, and you just need to download those files.

Use the SSH file transfer functions through psftp, pscp, WinSCP, or other similar tools:

C:\> pscp myserver:/var/log/myapp.log C:\Logs\myapp.log

C:\> psftp myserver
sftp> get /var/log/myapp.log
sftp> exit

If you actually need to run some special command to extract logs (cat does not count), it can be run using plink:

C:\> plink myserver "extract_logs > /tmp/myapp.log"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.