Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

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

  • 15-06-2018 11: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, Registered Users 2 Posts: 36,095 ✭✭✭✭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