-1

I've been having a lot of touble working out the problem with my code regarding ASCII art, the line in question is below:

PING localhost -n 1 >NUL
echo                                         '   ----' ""-.   \/ //
PING localhost -n 1 >NUL

Every time I get to it, it terminates the cmd prompt and throws The syntax of the command is incorrect - I suspect that I unknowingly picked the wrong order of a few characters in the specified line and accidentally began a command deriving from the echo command earlier.

As you will notice I've escaped my way through the first obstacle which was the first line off code, however the one after the pause command has me stumped.

I would like to know what symbols, or order of symbols caused this so I can refine the rest of my code. My code is:

echo                                        ___^<__^(^|^)_   ""-/\//\//
pause
PING localhost -n 1 >NUL
echo                                         '   ----' ""-.   \/ //
PING localhost -n 1 >NUL
echo                                                      )  ]  |
PING localhost -n 1 >NUL
echo                                               ____..-'  . /                          )
PING localhost -n 1 >NUL
echo                                           ,-""      __.,' /   ___                 /,
PING localhost -n 1 >NUL
echo                                          /    ,--""/ / / /,-""   """-.          ,'/
PING localhost -n 1 >NUL
echo                                         [    (    / /\/ /  ,.---,_   ._   _,-','
PING localhost -n 1 >NUL
echo                                          \    -./ / / /  /       -._  """ ,-'
PING localhost -n 1 >NUL
echo                                           -._  / / / /_,'            ""--"
PING localhost -n 1 >NUL
echo                                               "/ / / /"         
PING localhost -n 1 >NUL
echo                                               / /\/ /
PING localhost -n 1 >NUL
echo                                              / / / /  
PING localhost -n 1 >NUL
echo                                             / |,' /  
PING localhost -n 1 >NUL
echo                                            / /   |
PING localhost -n 1 >NUL
echo                                           [ //  ,'   
PING localhost -n 1 >NUL
echo                                           | / ,'
PING localhost -n 1 >NUL
echo                                           |/.-'
PING localhost -n 1 >NUL
echo                                           \-'`

timeout 3

:PASS
ECHO Slyshoiev en dyevet rhyzhok.
double-beep
  • 5,031
  • 17
  • 33
  • 41
Jinx
  • 3
  • 2

2 Answers2

1

The best way is to learn which characters need to be escaped. In the case of your 'so called' art, you only need to escape the < and | characters.

Please remove the two escape characters, ^, (otherwise known as carets), on your first line, which precede the parentheses, ) and (. You only need to escape the closing parentheses, ), if your art is within a parenthesised block.

Then just add the missing carets on the other five lines, in front of the five remaining pipe characters, |.

Example:

@Echo Off
Set "Delay=PathPing LocalHost -n -q 1 -p 250 >Nul"
Echo(
Echo                                 ___^<__(^|)_   ""-/\//\//
%Delay%
Echo                                  '   ----' ""-.   \/ //
%Delay%
Echo                                               )  ]  ^|
%Delay%
Echo                                        ____..-'  . /                          )
%Delay%
Echo                                    ,-""      __.,' /   ___                 /,
%Delay%
Echo                                   /    ,--""/ / / /,-""   """-.          ,'/
%Delay%
Echo                                  [    (    / /\/ /  ,.---,_   ._   _,-','
%Delay%
Echo                                   \    -./ / / /  /       -._  """ ,-'
%Delay%
Echo                                    -._  / / / /_,'            ""--"
%Delay%
Echo                                        "/ / / /"
%Delay%
Echo                                        / /\/ /
%Delay%
Echo                                       / / / /
%Delay%
Echo                                      / ^|,' /
%Delay%
Echo                                     / /   ^|
%Delay%
Echo                                    [ //  ,'
%Delay%
Echo                                    ^| / ,'
%Delay%
Echo                                    ^|/.-'
%Delay%
Echo                                    \-'`

Timeout 3 /NoBreak>Nul

:PASS
Echo Slyshoiev en dyevet rhyzhok.

Pause>Nul

I have used PathPing above instead of Ping, as it seems to give greater control of the delay speed, adjust 250 to possibly 125 and 500 to see the differences in speed. The last line is there just so that you get to see everything, you can remove it once you're happy with the output.

Compo
  • 36,585
  • 5
  • 27
  • 39
0

In the echo command, the characters that need to be escaped are <>|^&, ! when delayed expansion is enabled (with ^^!) and ) when echo is inside a parenthesized block.

In your code, you have characters <)|; you are not inside a parenthesized block, so you need to escape only characters <|. Your code should look like:

echo                                        ___^<_(^|)_   ""-/\//\//\
pause
PING localhost -n 1 >NUL
echo                                         '   ----' ""-.   \/ //
PING localhost -n 1 >NUL
echo                                                      )  ]  ^|
PING localhost -n 1 >NUL
echo                                               ____..-'  . /
PING localhost -n 1 >NUL
echo                                           ,-""      __.,' /   ___                 /,
PING localhost -n 1 >NUL
echo                                          /    ,--""/ / / /,-""   """-.          ,'/
PING localhost -n 1 >NUL
echo                                         [    (    / /\/ /  ,.---,_   ._   _,-','
PING localhost -n 1 >NUL
echo                                          \    -./ / / /  /       -._  """ ,-'
PING localhost -n 1 >NUL
echo                                           -._  / / / /_,'            ""--"
PING localhost -n 1 >NUL
echo                                               "/ / / /"         
PING localhost -n 1 >NUL
echo                                               / /\/ /
PING localhost -n 1 >NUL
echo                                              / / / /  
PING localhost -n 1 >NUL
echo                                             / ^|,' /  
PING localhost -n 1 >NUL
echo                                            / /   ^|
PING localhost -n 1 >NUL
echo                                           [ //  ,'   
PING localhost -n 1 >NUL
echo                                           ^| / ,'
PING localhost -n 1 >NUL
echo                                           ^|/.-'
PING localhost -n 1 >NUL
echo                                           \-'`

timeout 3

:PASS
ECHO Slyshoiev en dyevet rhyzhok.

Note: If you aren't sure which characters should be escaped, escape them all and test if your code is working. Then start removing some escape characters (optionally) and test the result! It has to work fine!

Interesting references:

double-beep
  • 5,031
  • 17
  • 33
  • 41