Redirecting 2 remote log files output from 1 bat file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
fedepia
Posts: 2
Joined: 31 May 2013 13:47

Redirecting 2 remote log files output from 1 bat file

#1 Post by fedepia » 31 May 2013 14:06

Hi guys, i need a hand on shell scripting.

To give you some context, I have a linux server and need to "tail -f" 8 log files. Nowadays, I have to open 8 putty consoles, redirect output to a file and execute in each console tail -f file1... tail -f file2... etc. After that, I have each log file being updated in live in my local workstation and can use tools like Baretail to process logs quite well.

This process is so annoying, so I started looking for a better process and found a very interesting way of improving it. I found that executing below command:

Code: Select all

(plink.exe -l user -pw password myhost tail -f SystemOut.log) > MySystemOut.log

...plink.exe (putty link) entablishes a connection to myhost, execute tail -f command on SystemOut.log, and using parentheses I redirect tail output to a local file on MySystemOut.log
This command works great although it never finish because tail -f is infinite.

I want to improve this process in order to create a bat file that carries out the following

Code: Select all

(plink.exe -l user -pw password myhost tail -f SystemOut.log) > MySystemOut.log
(plink.exe -l user -pw password myhost tail -f SystemErr.log) > MySystemErr.log
(plink.exe -l user -pw password myhost tail -f App.log) > MyApp.log

Can anyone give me a hand on this? I tried lots of things like using CMD, START but none worked for me.

Thanks a lot in advance!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Redirecting 2 remote log files output from 1 bat file

#2 Post by foxidrive » 31 May 2013 18:13

Your question is unclear - are you asking a scripting question or a question about plist?

fedepia
Posts: 2
Joined: 31 May 2013 13:47

Re: Redirecting 2 remote log files output from 1 bat file

#3 Post by fedepia » 03 Jun 2013 06:41

I have figured out how to solve it. I would like to share with everyone since i think this is quite useful for checking remote logs or backend applications.

The idea is to execute a .bat file to tail and follow several remote log files in our local environment to process them with logging tools like baretail:

Code: Select all

start /b cmd /c ^(plink.exe -l myUser -pw myPass my.host.net tail -f /logs/SIT/SystemOut.log^) ^> SystemOut.log
start /b cmd /c ^(plink.exe -l myUser -pw myPass my.host.net tail -f /logs/SIT/SystemErr.log^) ^> SystemErr.log
start /b cmd /c ^(plink.exe -l myUser -pw myPass my.host.net tail -f /logs/SIT/Application.log^) ^> Application.log
start /b cmd /c ^(plink.exe -l myDbUser -pw myDbPass db.host.net tail -f /logs/SIT/database.log^) ^> database.log


To STOP the application it is needed CTRL+Break (or ctrl+pause)

Hope it helps.

Regards,
Fede

Post Reply