none
echo redirection to a file adds a "1" character RRS feed

  • General discussion

  • I have a .cmd file (used to be a .bat file) with this in it:

    echo %date% %time% > .\prebuild.log
    echo Pre-Build Setup, Entry Code=%errorlevel% >> .\prebuild.log
    if exist .\Debug\Exe\%1.Hex Del .\Debug\Exe\%1.*
    echo Deleted DEBUG Files . . . >> .\prebuild.log
    if exist .\Release\Exe\%1.Hex Del .\Release\Exe\%1.*
    echo Deleted RELEASE Files . . . >> .\prebuild.log
    ::
    :EXIT
    ::
    echo Pre-Build Cleanup Complete, Exit Code=%errorlevel%  >> .\prebuild.log
    


    My output looks like this:

    $ echo Pre-Build Setup, Entry Code=1  1>>.\prebuild.log
    
    $ if exist .\Debug\Exe\apgatwoodv2.Hex Del .\Debug\Exe\apgatwoodv2.*
    
    $ echo Deleted DEBUG Files . . .  1>>.\prebuild.log
    
    $ if exist .\Release\Exe\apgatwoodv2.Hex Del .\Release\Exe\apgatwoodv2.*
    
    $ echo Deleted RELEASE Files . . .  1>>.\prebuild.log
    
    $ echo Pre-Build Cleanup Complete, Exit Code=1   1>>.\prebuild.log
    
    $
    

    Where is that "1" in front of the redirection characters coming from? It doesn't show up in my output file. Is there a better way to do this redirection? I'm asking because I'm running this script from inside an IDE and I'm getting odd results that may or may not be related.

    Thanks...

    • Changed type Bill_Stewart Monday, March 12, 2018 9:25 PM
    • Moved by Bill_Stewart Monday, March 12, 2018 9:25 PM Unanswerable drive-by question
    Tuesday, February 6, 2018 5:13 PM

All replies

  • 1 is normal. It's the file handle number and means "standard output."

    You don't say what "odd results" means or why you think the file handle number has anything to do with that.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, February 6, 2018 6:22 PM
  • Hi Bill - thanks for the response. I left out the other information because it's probably not germane to this topic. If the appearance of that character is normal, I'll just ignore it and look elsewhere for an explanation for my IDE issue.

    Thanks again.

    Tuesday, February 6, 2018 6:29 PM