Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why does pipe character in an echo line terminate batch routine?

339 views
Skip to first unread message

Joy

unread,
Jul 20, 2007, 7:17:37 PM7/20/07
to

I was enhancing a batch routine and tried to make the output fancy by
placing pipe characters (vertical bars) '|' in an echo command. I
couldn't figure out why the batch routine suddenly started to terminate in
an odd place until I realized what was happening.

I know about the pipe command, but never heard of this unexpected action.

Can anyone explain the reason or point me to a website documenting this
action?

I am using XP home edition SP2 fully patched.


For me, this routine terminates after the first pause


@echo on
rem Replacing any x in an echo line with the vertical
rem bar (|) terminates the batch routine

echo this is line 1
echo this is line 2
echo this is line 3 x
pause
echo this is | line 4
pause
echo x this is line 5
echo x
echo This is line 7
pause

Thanks,

Joy

Ted Davis

unread,
Jul 20, 2007, 8:19:29 PM7/20/07
to

You should get an error message like this:

'line' is not recognized as an internal or external command,
operable program or batch file.

Since the object following a pipe must be an executable program, "line 4"
is interpreted as an invocation of a program called "line" with the
argument "4". A missing executable is a fatal error, so the batch
terminates.


--
T.E.D. (tda...@umr.edu)

Joy

unread,
Jul 20, 2007, 9:59:59 PM7/20/07
to

Hi Ted,

I tried executing it in DOS mode and that is exactly what happens and I
understand why.

I was double clicking the batch file from windows (which is where I
usually kick off my batch files) and I don't get that error message. It's
like I said... it just terminates immediately with no error.

Guess it's just the way windows works.

Joy

foxidrive

unread,
Jul 21, 2007, 2:36:20 AM7/21/07
to
On Sat, 21 Jul 2007 01:59:59 GMT, Joy <Mycr...@yahoo.com> wrote:

>I was double clicking the batch file from windows (which is where I
>usually kick off my batch files) and I don't get that error message. It's
>like I said... it just terminates immediately with no error.
>
>Guess it's just the way windows works.
>
>Joy

Use ^| to echo a pipe character. ^ escapes special characters like < > | etc and even itself (^^)

echo this is a pipe character ^|

Richard Bonner

unread,
Jul 21, 2007, 12:56:27 PM7/21/07
to
Joy wrote:

> I was enhancing a batch routine and tried to make the output fancy by
> placing pipe characters (vertical bars) '|' in an echo command. I
> couldn't figure out why the batch routine suddenly started to terminate in
> an odd place until I realized what was happening.

> For me, this routine terminates after the first pause

> @echo on
> rem Replacing any x in an echo line with the vertical
> rem bar (|) terminates the batch routine

> echo this is line 1
> echo this is line 2
> echo this is line 3 x
> pause

(Snip)

> Joy

*** I am work right now and happen to be on a computer that runs MS-DOS
6.2 for compatibility reasons I won't get into here. As I see it, the
reason it terminates is because there is nothing given to which to pipe.

I tried this at the command line on this system:

ECHO THIS IS A PIPE CHARACTER |

And got "syntax error".

I then tried:

ECHO THIS IS A PIPE CHARACTER "|"

That displays properly as:

THIS IS A PIPE CHARACTER "|"


I also tried redirecting the above to a file and that worked too.

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

Ted Davis

unread,
Jul 21, 2007, 1:00:07 PM7/21/07
to

X-Signature: default

That's specific to NT series OSs - this is the other newsgroup.

--
T.E.D. (tda...@umr.edu)

foxidrive

unread,
Jul 21, 2007, 2:06:45 PM7/21/07
to
On Sat, 21 Jul 2007 12:00:07 -0500, Ted Davis <tda...@umr.edu> wrote:

>On Sat, 21 Jul 2007 16:36:20 +1000, foxidrive wrote:
>
>> On Sat, 21 Jul 2007 01:59:59 GMT, Joy <Mycr...@yahoo.com> wrote:
>>
>>>I was double clicking the batch file from windows (which is where I
>>>usually kick off my batch files) and I don't get that error message. It's
>>>like I said... it just terminates immediately with no error.
>>>
>>>Guess it's just the way windows works.
>>>
>>>Joy
>>
>> Use ^| to echo a pipe character. ^ escapes special characters like < > | etc and even itself (^^)
>>
>> echo this is a pipe character ^|
>

>That's specific to NT series OSs - this is the other newsgroup.

Richard Bonner

unread,
Jul 22, 2007, 9:54:45 AM7/22/07
to
Joy wrote:

> I was enhancing a batch routine and tried to make the output fancy by
> placing pipe characters (vertical bars) '|' in an echo command.

(Snip)
> Joy

*** As a followup, I should mention Norman De Forest's wonderful
EKKO.com program, an update to the DOS "ECHO" command. It can echo any
PROMPT meta strings to the screen or to a file. So:

EKKO $B

will output: |


EKKO does many other things. A link is at:

http://www.chebucto.ca/~ak621/DOS/Websites.html


Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

Todd Vargo

unread,
Jul 22, 2007, 11:16:29 AM7/22/07
to

Point of fact, Norman De Forest's EKKO.com program is not and update to the
DOS "ECHO" command. It is merely on of many 3rd party add on utilities.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


Richard Bonner

unread,
Jul 22, 2007, 7:34:02 PM7/22/07
to
Todd Vargo wrote:

> Richard Bonner wrote:
> > *** As a followup, I should mention Norman De Forest's wonderful
> > EKKO.com program, an update to the DOS "ECHO" command.

> Point of fact, Norman De Forest's EKKO.com program is not and update to the

> DOS "ECHO" command. It is merely on of many 3rd party add on utilities.
> --
> Todd Vargo

*** I'm sorry, I mis-spoke. Yes, EKKO cannot completely emulate the DOS
"ECHO" command and so is not an update. One could not use "EKKO OFF" at
the start of a batch file, as an example. Still, it's a wonderful program.

Thanks for the correction, Todd.

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

0 new messages