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
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)
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
>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 ^|
> 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/
X-Signature: default
That's specific to NT series OSs - this is the other newsgroup.
--
T.E.D. (tda...@umr.edu)
>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.
> 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/
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)
> 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/