tia, but I'm wondering if there's a way to redirect a tomcat startup.bat call into a text file.

Here's my situation: I open cmd, navigate to the needed directory, and call 'startup.bat' This opens up a "Tomcat" java window, which is exactly like a command prompt, which is where all the log information goes.

A workaround is increasing the buffer size, but is there anyway to redirect a new command prompt into a file? It'd be easy if you called 'startup.bat' and it did all the work in the same command prompt (a simple > would do), but not sure what to do with a newly opened window.

  • Check startup.bat and see how it's opening up the new window. Is it calling another batch file or running an EXE? Whatever be the case, you can edit the batch file involved to redirect to a text file. – Karan Jun 5 '15 at 19:45
  • thanks for your response. it calls another batch file (catalina.bat), which echos pretty much everything I want. am i going to have to go through every echo and change those or is there an easier way? – st0rkhunter Jun 5 '15 at 19:52
  • You can edit the line where startup.bat calls catalina.bat and see if redirecting that to a text file works. BTW have you also checked out the TOMCAT\logs\catalina.<date>.log files? – Karan Jun 5 '15 at 19:54
  • seemed like a good idea, but it only saved the output (just sys variable information) to the text file. within 'startup.bat', changing where the other bat is called 'call other.bat > txt.txt' is similar to when i run 'startup.bat > txt.txt' dammit! @karan you are the best. good call. those log files slipped my memory - now to handle this memory leak. hahah thanks you :) – st0rkhunter Jun 5 '15 at 20:03
  • If the catalina log files aren't sufficient then there is a way to do what you want with a custom log4j config. – Karan Jun 5 '15 at 20:23

Commands that use Somecommand > somefile must be run by command (cmd), since command handles the redirection. You can handle redirection yourself. This captures forfiles like cmd would.

Set Inp = WScript.Stdin
Set Outp = Wscript.Stdout
Set cmd = CreateObject("Wscript.Shell").Exec("forfiles")
cmd.stdin.writeline "dir"
cmd.stdin.writeline "exit"
Do While Not cmd.stdout.AtEndOfStream 
    results = cmd.stdout.readall
    If err.number <> 0 then Exit Do
    wscript.echo results

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.