Page 1 of 1

cannot use echo. with set/p and |

Posted: 21 Feb 2014 10:15
by taripo
This works as expected

Code: Select all

C:\>set/p=AAAAAAAA^|BBBBBBB
AAAAAAAA|BBBBBBB

C:\>


But I don't want to have to hit ENTER.

But if I do this, it doesn't work as expected.. I want it to do like the above but hitting ENTER

Code: Select all

C:\>echo.|set/p=AAAAAAAA^|BBBBBBB
'BBBBBBB' is not recognized as an internal or external command,
operable program or batch file.

C:\>


ultimately I want to do

Code: Select all

C:\>echo AAAAAA^|BBBBB>c:\crp\f.fff

C:\>


But without the CRLF at the end. So i'm using the echo.|set /p=_____ technique. But it's not working when the thing after the = contains a |

Re: cannot use echo. with set/p and |

Posted: 21 Feb 2014 10:46
by rodrigolima
Hello taripo

Try this:

>echo.&set/p=AAAAAAAA^|BBBBBBB [ENTER]

I hope that it be helpful for you.

See you

Re: cannot use echo. with set/p and |

Posted: 21 Feb 2014 11:00
by carlos
try use a file as input, in this case the nul special file that not have any data.

Code: Select all

set/p "=AAAAAAAA|BBBBBBB" <nul

Re: cannot use echo. with set/p and |

Posted: 21 Feb 2014 11:15
by taripo
Thanks carlos that <nul solution e.g. set/p=dd^|fds<nul and set/p"=dd|fds"<nul works.

Rodrig, that which you mentions doesn't work, you still have to hit enter. The point was me not having to hit ENTER.

Re: cannot use echo. with set/p and |

Posted: 21 Feb 2014 14:11
by jeb
Only for completness, you need three carets when using a pipe, or quote it

Code: Select all

echo. | set/p=AAAAAAAA^^^|BBBBBBB
echo. | set /p "=AAAAAAAA|BBBBBBB"


But at all this is a bad solution, carlos tip to use <nul is better, as it's much faster and with fewer problems

jeb

Re: cannot use echo. with set/p and |

Posted: 21 Feb 2014 16:19
by taripo
thanks..
so


looking at these 4 solutions

noted that <nul is better than echo.| or echo;|
so the latter two are the way to go

- echo. | set/p=AAAAAAAA^^^|BBBBBBB
- echo. | set /p "=AAAAAAAA|BBBBBBB"
- set/p "=AAAAAAAA|BBBBBBB" <nul
- set/p=AAAAAAAA^|BBBBBBB <nul


is the fourth one as good as the third one?

And why does the first one require that | to be escaped 3 times?