1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I/O redirection with start command.

Discussion in 'Support' started by krischik, Sep 6, 2010.

  1. krischik

    Joined:
    Feb 20, 2009
    Messages:
    46
    Likes Received:
    1
    I have tied quite a few combinations but I was not able to redirect I/O from a start command. Something like:

    Code:
    START X.EXE >&X.out
    
    With X.EXE beeing a GUI applications writing stuff the the console I don´t want to see normally (but keeping the output in a log file would be nice for debugging).

    I found an article on CMD but the ^ trick described won´t work with TCMD.

    Any hints or is it hopeless?

    Martin
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,859
    Likes Received:
    83
    If the GUI app is creating its own console, then it's hopeless. Redirection
    is done by the command processor, not by Windows, and in this case the
    command processor would never be invoked.

    If X.EXE is not creating a new console (and is not really a GUI app), you'd
    need to use a command group to capture the output of X.EXE. (In your
    example above, you're redirecting the output of START, not the output of
    X.EXE.)

    Rex Conn
    JP Software
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30
    What if x.exe is a GUI app attaching to the console of its parent (AttachConsole(-1))? I wrote a little test (GUI) which did that and wrote "Hello world." both with WriteConsole() and with wprintf() (after setting up stdout). It works fine if I just give its name at the TCC command line but I can't figure out a way to capture its output (tried START /wait /b and command grouping). I couldn't do it with CMD either. Do you think it's possible?

    The example the OP found was

    Code:
    START CMD /C essmsh CSR.build.outline.CSRCALC.mxl^>CSRCALC.LOG
    But essmsh itself is a console app.
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,859
    Likes Received:
    83
    GUI apps normally do not inherit stdio handles; you have to go to quite a
    bit of extra work to manage that. Simply attaching to a console does not
    infer any handle inheritance.

    Rex Conn
    JP Software
     
  5. krischik

    Joined:
    Feb 20, 2009
    Messages:
    46
    Likes Received:
    1
    The very first line printed is:

    So it seems that the app does indeed attach to to existing console. As do most Java applications.

    The following two options did not work out:

    Code:
    (START X.EXE ) >&X.out
    START (X.EXE  >&X.out)
    
    So I guess it is all down to some Window-Magic as vefatica pointed out and the whole stuff is hopeless.
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,859
    Likes Received:
    83
    The only way it could work is if the GUI app did some custom magic at startup to use the console handles passed by TCC. (I've never seen *any* GUI app other than TCMD that does this.)
     
  7. krischik

    Joined:
    Feb 20, 2009
    Messages:
    46
    Likes Received:
    1
    Well, the console message suggest that some extras magic is done. It is ok, a very special case and not much one can do about.

    If you want to see one: http://netbeans.org/ ;-).
     

Share This Page