I can open a cmd window and start a tail by entering something like this:
tail -f C:\Oracle\WebCenter\Sites\11gR1\Sites\11.1.1.6.1\logs\sites.log
This is probably a stupid question, but how do I do this in a batch file?
It should be easy but it's not working - I have tried a couple variations and no success. Can anyone tell me what I am doing wrong here?
ECHO OFF
CD C:\Oracle\WebCenter\Sites\11gR1\Sites\11.1.1.6.1\logs\
cmd
tail -f sites.log
I've also tried:
ECHO OFF
start cmd tail -f C:\Oracle\WebCenter\Sites\11gR1\Sites\11.1.1.6.1\logs\sites.log
(am using Win7 Ultimate, on a 64-bit machine, if that has any bearing)
Answer
I can beat that. Just make a shortcut and put this in the target field:
cmd.exe /K tail.exe "C:\Oracle\WebCenter\Sites\11gR1\Sites\11.1.1.6.1\logs\sites.log"
It's a one liner so no need for a BATCH file.
If you did want a script file, then do this:
@echo off
tail.exe "C:\Oracle\WebCenter\Sites\11gR1\Sites\11.1.1.6.1\logs\sites.log"
or just
@tail.exe "C:\Oracle\WebCenter\Sites\11gR1\Sites\11.1.1.6.1\logs\sites.log"
since it's only 1 line.
I'm going to guess that the problem you had was that you named your BATCH file tail.bat
. Then inside it you just used tail C:\Oracle\WebCenter\Sites\11gR1\Sites\11.1.1.6.1\logs\sites.log
. This caused your script to reference itself because DOS is going to look in the current dir first. It would've ended up calling tail.bat C:\Oracle\WebCenter\Sites\11gR1\Sites\11.1.1.6.1\logs\sites.log
over and over again.
Update
If you want the window to stay open then you have a few options. You can use the pause
command:
@tail.exe "C:\Oracle\WebCenter\Sites\11gR1\Sites\11.1.1.6.1\logs\sites.log"
@pause
or you can lauch a new shell inside the terminal which stays open after it finishes. This will cause the parent shell to remain open as well as the terminal itself:
@cmd.exe /K tail.exe "C:\Oracle\WebCenter\Sites\11gR1\Sites\11.1.1.6.1\logs\sites.log"
The pause
command is good if you want the window to close easily. Just press any key and it's gone. The second option is better if you typically want to run other commands after it runs.
No comments:
Post a Comment