using unix/linux Tail command in windows 10.

This is not so much a question as a passing on of a tip.

I have been working with Nixie and windows 10 and had on various occasions a need for a running tally of the log file. In linux/unix this is easy, just use the tail command and Bob's yer uncle as they say.

That quest wasn't as straight forward in windows, but, to the rescue windows PowerShell [PS]. PS is very powerful and out of the box comes with restrictions. To be able to run scripts you have to tell PS that it is ok to trust local scripts. To do this run  PS in admin mode then execute the following command:

Set-ExecutionPolicy RemoteSigned. then answer yes to the allow question.

in notepad, enter the one-liner: Get-Content /nixie/myrobotlab.log -Wait   and save it with a .ps1 extension. I named mine followlog.ps1 and saved it in my nixie directory. you can name yours whatever u like, just adjust the scripts below.

now anytime you want to do a running tail on yer log file just right click on followlog.ps1 and choose Run with PowerShell. (double clicking, for apparent security reasons, opens the file in notepad)

 

I modified my START_INMOOV.bat file to start the script automatically.

first off, change the line mv myrobotlab.log myrobotlab.log.1 to move /y myrobotlab.log myrobotlab.log.1 as mv is not recognized in windows.

 

next add the following two lines after the altered move line:

fsutil file createnew myrobotlab.log 0
START powershell -file "c:\nixie\followlog.ps1"
 
The fsutil line will create an empty log file as u just deleted the current lof file by moving it to the backup file. PS is going to need a file to start with, so the fsutil line will create an empty one.
the START line will spawn a PS window tailing the log file as lines are added.
 
now every time u start inmoov with the bat file, in windows 10, u will have a window showing you the latest lines in the log file.
 
 
GroG's picture

Thanks for the tip rv8flyboy

Thanks for the tip rv8flyboy !
In the past I've used cygwin for Linux commands on windows - https://www.cygwin.com/ 

There is a service called Log in mrl - that will "tail the log" regardless of platform .. and do it remotely
It has filtering too .. I should update the service page http://myrobotlab.org/service/log

rv8flyboy's picture

Hey Grog yes i am aware of

Hey Grog

yes i am aware of the log service 

I even used it .. lol

I had some issues early on where somewhere during the startup sequence the swing gui would abruptly close, giving me no time to even consider looking at the log service, or even send a NoWorky.

I also had occasions where the startup script would come to a grinding halt and nothing more could/would be done, it would just sit there staring at me.

hence my quest for a tail substitute, tried some 'for windows' packages, but then found the PowerShell command and thought it was elegant, worthy of sharing