Kaseya Community

echo to text files without CRLF

  • Sometimes within procedures, i write specific information to text files for later use, or to pick up with other procedures.

    For this the easiest way for me is to run a Execute Shell Command and do a: echo #VAR# >> c:\mytext.txt

    The bad thing about this is when reading this file into a variable (get variable from file) you end up that kaseya in also reading the CRLF produced by the echo command, which can result in extra spaces which are not handy if you use this variable to build up running a executable with arguments.

    The trick to do a echo to a file without ending op with a CRLF in the file is to do the echo as follows with the execute shell command:

    echo (.|set /p="#VAR#")>>c:\mytext.txt



  • Good one!

    I've used a vbscript to strip out CRLFs in the past. I'll try to dig it up and post it -- I had some odd characters that weren't being stripped by using the set shell command like this.