"The process tried to write to a nonexistent pipe." bat file

13,538

You've introduced an additional whitespace character before the pipe, |. The caret, ^, therefore has the effect of escaping the whitespace and the pipe isn't escaped as it should be.

@For /F "Tokens=2" %%i In ('arp -a ^| Find /I "dynamic"') Do @(Echo %%i)>>"%~dp0output.txt"
Share:
13,538
user8785018
Author by

user8785018

Updated on June 28, 2022

Comments

  • user8785018
    user8785018 almost 2 years

    I can run on command line this loop:

    for /f "tokens=2" %i in ('arp -a ^| Find/i "dynamic"') do echo %i
    

    but if I run the same bat file I get:

    ^C^C^C^Cthe process tried to write to a nonexistent pipe^C^C^C^C^C^C^C^C^
    

    C:\1\test.bat:

    for /f "tokens=2" %%i in ('arp -a ^ |Find/i "dynamic"') do echo %%i
    

    Returned by your arp -a command:

    C:\Users\test>arp -a
    Interface: xxx.xx.xxx.40 --- 0xbe
    Internet Address      Physical Address
     xxx.xx.xxx.18           xx-xx-xx-xx-xx-xx     dynamic
     xxx.xx.xxx.26           xx-xx-xx-xx-xx-xx     dynamic
     xxx.xx.xxx.34           xx-xx-xx-xx-xx-xx     dynamic
     xxx.xx.xxx.114          xx-xx-xx-xx-xx-xx     dynamic
    

    thanks for any help //Simon