Bug in command prompt's ECHO?

G

Guest

I am trying to echo a message and pipe it to another program. The problem is
that the message contains spechal characters.

The caret ^ can be used as escape for special characters. So, if I type

H:\>echo ^<

I get the correct output

<

The same happens if I redirect output to a file

H:\>echo ^< > test.txt

test.txt contains the right message.

But redirection to pipe seems to be broken.

H:\>echo ^< | more
The syntax of the command is incorrect.

What's the problem? Is there a solution or workaround?
 
P

Pegasus

fab said:
I am trying to echo a message and pipe it to another program. The problem
is
that the message contains spechal characters.

The caret ^ can be used as escape for special characters. So, if I type

H:\>echo ^<

I get the correct output

<

The same happens if I redirect output to a file

H:\>echo ^< > test.txt

test.txt contains the right message.

But redirection to pipe seems to be broken.

H:\>echo ^< | more
The syntax of the command is incorrect.

What's the problem? Is there a solution or workaround?

The command
echo ^< | more
will pipe the string "<" to more.com. I suspect that more.com
is unable to deal with it. The "echo" command works just fine.

Your command is rather strange. What exactly are you trying
to achieve?
 
G

Guest

I was trying to send a string containing the character > to a program through
pipe. And I think it is not more's fault, as the same problem occurs with all
other programs, not just "more".

I used "more" just as an example, it's not the program I want to use.
 
P

Pegasus

You can walk around the problem using this syntax:
@echo off
echo ^< > c:\temp.txt
type c:\temp.txt | more

If you're interested in someone digging his teeth into this
one then you should repost your question here:
alt.msdos.batch.nt
They love this type of challenge!
 
P

Poprivet

fab said:
I am trying to echo a message and pipe it to another program. The
problem is that the message contains spechal characters.

The caret ^ can be used as escape for special characters. So, if I
type

H:\>echo ^<

I get the correct output

<

The same happens if I redirect output to a file

H:\>echo ^< > test.txt

test.txt contains the right message.

But redirection to pipe seems to be broken.

H:\>echo ^< | more
The syntax of the command is incorrect.

What's the problem? Is there a solution or workaround?

See alt.msdos.batch.nt - those guys can tell you exactly how. I know you
have to "esc" the character, but not how to at the moment. IF it's
possible, those guys will know how. And, you can quote me on that <g>.

HTH
Pop`
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top