Reputation: 13207
I have
C:\folder\tail.exe
C:\logs\logfile.log
C:\script\shellscript.ps1
How do I run the C:\folder\tail.exe from within the C:\script\shellscript.ps1
I need to run "C:\folder\tailf.exe C:\logs\logfile.log" from within C:\script\shellscript.ps1 but without relying a seperate batch file, i need to call it directly.
Normally I do: cd C:\folder\ and then tailf.exe C:\logs\logfile.log
Inside C:\script\shellscript.ps1 I tried
start-process C:\fetchmail\tail.exe -argumentlist "C:\fetchmail\logs\fetchmail.log"
i can see a window flashing but dont know if it works, the window should stay open.
Upvotes: 2
Views: 4981
Reputation: 16616
To accomplish tail.exe running in a separate window and not having the window closed immediately, try:
cmd /k c:\folder\tail.exe c:\logs\test.log
To start tail.exe in the powershell window, try:
C:\folder\tail.exe c:\logs\logfile.log
Assuming tail.exe
is Tail for Win32, this is a powershell equivalent of your command:
get-content c:\logs\logfile.log | select -last 10
In the Powershell Community Extensions there is a Get-FileTail cmdlet which is a more efficient native powershell tail equivalent.
Upvotes: 3
Reputation: 301037
You can do what you normally do:
C:\folder\tail.exe c:\logs\logfile.log
Note that if the paths have spaces in them you have to do:
& "C:\fol der\tail.exe" "c:\log s\logfile.log"
Upvotes: 7