Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Outputting results of a bat h file to one single line instead of multiple lines.

  • 15-06-2018 10:31pm
    #1
    Closed Accounts Posts: 5,756 ✭✭✭


    Hi,
    I have a small piece of software that was developed by someone else , It is for performance monitoring purposes for a specific supplication.

    When I run it using the specified arguments it requires , its results are output line by line.

    I set up a batch file that will run the .exe with the correct arguments , and then out put the results to a log file, and that works great.

    What I would like to achieve is to have the results printed to the log file on one line each time the batch file is run.

    Here is the batch script currently:


    @echo off

    >>C:�\Test_SimTX\test.txt (

    echo [%date% %time%]

    "C:\data\test.exe"
    Echo Done!
    )


    The results will be output like this (this is when run 3 times in a row):

    [15/06/2018 17:20:10.10]
    Connecting to Server.
    Sending Message to Server.
    Waiting for Response.
    Response: OK - Took: 1.325983
    Done!
    [15/06/2018 17:31:04.20]
    Connecting to Server.
    Sending Message to Server.
    Waiting for Response.
    Response: OK - Took: 1.0607864
    Done!
    [15/06/2018 17:32:06.31]
    Connecting to Server.
    Sending Message to Server.
    Waiting for Response.
    Response: OK - Took: 1.37
    Done!

    This is fine, but I would like to make each write to the log display as below:

    [15/06/2018 17:32:06.31] Connecting to Server. Sending Message to Server. Waiting for Response. Response: OK - Took: 1.37 Done!


    Anyone have any ideas?

    I found something after a few mins of google to try using set /p , but it has not worked in any way, I might be using it incorrectly.


Comments

  • Registered Users Posts: 36,161 ✭✭✭✭ED E


    Its writing directly to the log on each operation, you need to make a "buffer" to load your data into.

    The flow should be:
    Create var
    Append timedate
    Append output from exe
    Strip all newlines from var
    Write var to logfile

    I use batch infrequently so I won't try and write this up but with a few mins on StackOverflow you should get it going.


Advertisement