Thanks Graham
Sure. The angle brackets redirect output. It allows you to dump the line
being echoed to an alternate location, like a file. For example...
ECHO Correct Usage is BLAH > blah.txt
If you type BLAH.TXT, you'll see "Correct Useage is BLAH". You can also
redirect things to "nul". This is useful for things like PAUSE, when you
don't want to see "Press Any Key to Continue..."
PAUSE > NUL
If you use double angle brackets, it adds to the file, rather than replacing
it. Example...
ECHO Hello >> blah.txt
Now BLAH.TXT would contain...
Correct Useage is BLAH
Hello
Perhaps one of the other readers will know if it is possible to use ">" inside
of the ECHO without it redirecting. The above explains your problem, though.
8^)
============================================
Reading Scientific Co., Inc.
* Quality chemistry products from the most respected
suppliers and manufacturers in the industry.
http://members.aol.com/readingsci/readingsci.html
E-mail: Readi...@aol.com
If intended strickly for display, the simplest solution is to inclose
the less than/greater than signs (< & >) with double quotes, something
like this ...
echo "Correct Usage is BLAH <filename>"
If the presence of the quotes is objectionable, follow them with the
backspace character (ASCII 8, [Ctrl-P followed by Ctrl-H in DOS EDIT)
and at least one more character. For example,
echo "^HCorrect Usage is BLAH <filename>"^H[space]
Where the ^H stands for the backspace character. Note the trailing
space after the second Ctrl-H. The backspace in an ECHO is
non-distructive. The extra character overwrites the offending quote.
There is another approach that uses characteristics of the PROMPT
command, but it is a bit more involved. I have developed a little batch
file to automate the process. I am in the process of adding a page to
my web site to explain its function and use. Briefly, the procedure,
ANSI.BAT, simplifies the use of dollar sign substitution symbols for the
troublesome less than/greater than and vertical bar characters. The
procedure has just four working lines:
:: ANSI.BAT - Makes using ANSI control sequences easy.
:: Tom Lavedas <tlav...@www.deltaelectronics.com>
:: http://www.deltaelectronics.com/tglbatch/
@echo %dbga% off
> %ram%.\}A{.bat echo @prompt %1
> %ram%.\}B{.bat %comspec% /e:2048/c }A{
for %%v in (%ram%.\}B{.bat del) do call %%v %ram%.\}?{.bat
:: A line needed to surpress extra line feed created by FOR
In your case, it would be called thus ...
set temp=Correct Usage is BLAH $lfilename$g
call ansi echo.%%temp%%
set temp=>nul
The two problem characters are replaced by the $l and $g substitutions.
I developed ANSI.BAT to help with displaying ANSI control strings (so
called Escape sequences), but have found it to be useful for all kinds
of things. Try, for example, ...
ansi echo.$_Date:$d$_Time:$t$_
or
ansi set$qDate$q$d$_set$qTime$q$t
For more information on the available substitutions try HELP PROMPT from
a command prompt.
Tom Lavedas
-----------
Delta Electronics, Inc.
http://www.deltaelectronics.com/tglbatch/
>Can anyone let me know why I'm getting error messages when I include
>angle brackets ie < >in an echo command, such as:
>echo Correct Usage is BLAH <filename>
>
@echo @prompt Do it like this $l filename $g >2temp2.bat
@command/c 2temp2 >3temp3.txt
@type 3temp3.txt
Tested in Win95 DOS, however I suggest you don't use a statement
with < or > in this way as those symbols are used for redirection in
DOS. BTW, if it's the file name you want, use %0.
echo This file is %0
regds Geoff Thursday, 1997-11-13
gcu...@melbpc.org.au (address expires Mar 98)
echo Correct Usage is "BLAH <filename>"
will work, as will
"echo Correct Usage is BLAH <filename>"
If you can live with the "", you can avoid rather a lot of work.