cannot use echo. with set/p and |

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
taripo
Posts: 227
Joined: 01 Aug 2011 13:48

cannot use echo. with set/p and |

#1 Post by taripo » 21 Feb 2014 10:15

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 |

rodrigolima
Posts: 21
Joined: 19 Jul 2013 11:35
Location: Brazil

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

#2 Post by rodrigolima » 21 Feb 2014 10:46

Hello taripo

Try this:

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

I hope that it be helpful for you.

See you

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

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

#3 Post by carlos » 21 Feb 2014 11:00

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

taripo
Posts: 227
Joined: 01 Aug 2011 13:48

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

#4 Post by taripo » 21 Feb 2014 11:15

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.

jeb
Expert
Posts: 1043
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

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

#5 Post by jeb » 21 Feb 2014 14:11

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

taripo
Posts: 227
Joined: 01 Aug 2011 13:48

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

#6 Post by taripo » 21 Feb 2014 16:19

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?

Post Reply