how to log cmd output to file & display it on the screen

Discussion in 'Computing and Networks' started by KMK, Jun 22, 2013.

  1. KMK

    Thread Starter Active Member

    Feb 11, 2010
    68
    0
    hi,

    i need a way to log the output of command prompt in a file & at the sam time, the executed command should be displayed on screen.

    Eg. when i issue ping command, it should display the ping results on screen realtime & log the same to a file.
     
    Last edited: Jun 22, 2013
  2. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,815
    834
    Search online for "tee.exe for Windows". I don't know which base OS (Windows server versus Windows 7 for example) you are using, but this is the command you're looking for.

    Then, pipe the output from your command (e.g., "ping") to tee and specify your output file. Output will go to both the screen (standard output) and the file.

    Ping 127.0.0.1 | tee pingout.txt
     
    Last edited: Jun 22, 2013
  3. KMK

    Thread Starter Active Member

    Feb 11, 2010
    68
    0
    im using Windows XP & 7. Are there any commands in the CMD of the OS that can be used for this prupose, without having to install the "tee.exe" ?
     
  4. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,815
    834
    No. Tee is a simple servlet, which I installed as a package of Linux shell tools to extend Windows cmd commands. But you only need the one command.
     
  5. darklighterz

    New Member

    Jun 17, 2013
    19
    0
    tee.exe is the best option tbh, but you could also use something like this (however it wont be realtime but just after the command has completed)

    ping www.google.com > google_ping_log.txt & type google_ping_log.txt
     
Loading...