Computer Hope

Microsoft => Microsoft DOS => Topic started by: belka on October 22, 2009, 12:37:55 AM

Title: batch file with ASCII art
Post by: belka on October 22, 2009, 12:37:55 AM
Hi guys,

I have a little batch file created which runs fine as attended.
But after adding just a simple ASCII art (as introduction) it's failing. It's just started up for a tiny second and is closed again immediately?!

This I added:

echo     _
echo    _( )_
echo   (_(%)_)
echo     (_)\
echo         | __
echo         |/_/
echo         |
echo         |

... and nothing else. :-/
Is there anybody being able to help out?

Thank you!
Title: Re: batch file with ASCII art
Post by: Dusty on October 22, 2009, 02:05:04 AM
Quote from: belka
echo     _
echo    _( )_
echo   (_(%)_)
echo     (_)\
echo         | __      <------
echo         |/_/       <------
echo         |           <------
echo         |           <------

You are using the 'pipe' so the Command Interpreter expects a valid command after it but finds __ instead.  This is invalid so the script fails the first time the 'pipe' is used.  To correct this Escape the pipes.

& Welcome to the CH forums..
Title: Re: batch file with ASCII art
Post by: belka on October 22, 2009, 02:43:01 AM
Quote
You are using the 'pipe' so the Command Interpreter expects a valid command after it but finds __ instead.  This is invalid so the script fails the first time the 'pipe' is used. 

Aah, and I've already been afraid of that stuff. 

Quote
To correct this Escape the pipes.

I had to prefix them with carets?! I did that for all pipes but failed again.
What are all relevant special characters and symbols in this regard?

Quote
& Welcome to the CH forums..

Thanks.  :-)


Thank you.
Title: Re: batch file with ASCII art
Post by: Dusty on October 22, 2009, 03:55:18 AM
I Escaped the pipes using the caret and the script ran without problem.

echo ^|__
echo ^|/_/
echo ^|
echo ^|

Title: Re: batch file with ASCII art
Post by: belka on October 22, 2009, 04:02:43 AM

... I failed. But after prefixing also '<',  '>' and '_' it ran!  :-)

Maybe there is a whole bunch of special characters needing a such special treating?!

Thanks so far!
Title: Re: batch file with ASCII art
Post by: Dusty on October 23, 2009, 01:18:34 AM
There's a list here (http://ss64.com/nt/syntax-esc.html)..

Title: Re: batch file with ASCII art
Post by: belka on October 23, 2009, 03:29:43 AM

There's a list here (http://ss64.com/nt/syntax-esc.html)..

Thank you!

Quoting from there:
When piping or redirecting any of these charcters you should
     prefix with the escape character: \ & | > < ^
     e.g.  ^\  ^&  ^|  ^>  ^<  ^^
end of quoting

As you can see this shouldn't be a _complete_ list because I had to prefix ' _ ' in my batch, too?!

Title: Re: batch file with ASCII art
Post by: BC_Programmer on October 23, 2009, 10:31:29 AM
No. the underscore has no special meaning to the command interpreter and therefore does not require escapement.
Title: Re: batch file with ASCII art
Post by: belka on October 23, 2009, 02:53:04 PM
No. the underscore has no special meaning to the command interpreter and therefore does not require escapement.

Well, that may be or not. In fact I had to prefix even all underline characters (not 'underscore') in order to get my batch running. But maybe there is a 'hidden truth'?
That's why here again what I did for another example:

echo              ^_^_     ^_^_
echo             .'  `...'  `.
echo           ^_^_^|     ^|     ^|^_^_
echo         .'    \   .   /    `.
echo         ^|      ./###\.      ^|
echo          ^>---- ^|#####^| ----^<
echo         ^|      `\###/'      ^|
echo         `.^_^_ /    .    \ ^_^_.'
echo            /^|     ^|     ^|
echo           / `.^_^_^_.^.^_^_^_.'
echo          ^|
echo          ^|   
echo           \               
echo            \             )\
echo             `.          /' ^|
echo               \       /'   )
echo                \    /'    /'
echo                 \  /'    /'
echo                  \(    /'
echo                   )  /'
echo                   ^| /'
echo                   ^|( 
echo                   ^|^|

Thank you.
Title: Re: batch file with ASCII art
Post by: Dusty on October 23, 2009, 03:07:55 PM
Belka - your script works perfectly without the underline (underscore) characters being escaped.


Try this, works for me, tested on Win2k, Win2k.Pro, Win XP.HE and Win XP Pro.
Code: [Select]
@echo off
cls

echo              __     __
echo             .'  `...'  `.
echo           __^|    ^|     ^|__
echo         .'    \   .   /    `.
echo         ^|      ./###\.      ^|
echo          ^>---- ^|#####^| ----^<
echo         ^|      `\###/'      ^|
echo         `.__ /    .    \ __.'
echo            /^|     ^|     ^|
echo           / `.___..___.'
echo          ^|
echo          ^|
echo           \
echo            \             )\
echo             `.          /' ^|
echo               \       /'   )
echo                \    /'    /'
echo                 \  /'    /'
echo                  \(    /'
echo                   )  /'
echo                   ^| /'
echo                   ^|(
echo                   ^|^|
Title: Re: batch file with ASCII art
Post by: BC_Programmer on October 23, 2009, 11:02:21 PM
Although when you do escape them, it has a bunch of anime smiley's...  ;D
Title: Re: batch file with ASCII art
Post by: belka on October 24, 2009, 04:16:33 AM
Belka - your script works perfectly without the underline (underscore) characters being escaped.

I admit you're right. I checked it renewed. Ago I got a failing, no idea what happened.

Okay, in this way we both learned something new.
Thank you for reliable supporting.