Trying to show the ASCII art text "Hotdog Water" (don't ask) line by line, and it's not working. The Command Prompt window closes after the first line has been displayed.
My code is in this Gist.
Thanks in advance!
CodePudding user response:
Here's your code:
@echo off
echo _ _ _ _ __ __ _
timeout 1 > nul
echo | | | | | | | | \ \ / / | |
timeout 1 > nul
echo | |__| | ___ | |_ __| | ___ __ _ \ \ /\ / /_ _| |_ ___ _ __
timeout 1 > nul
echo | __ |/ _ \| __/ _` |/ _ \ / _` | \ \/ \/ / _` | __/ _ \ '__|
timeout 1 > nul
echo | | | | (_) | || (_| | (_) | (_| | \ /\ / (_| | || __/ |
timeout 1 > nul
echo |_| |_|\___/ \__\__,_|\___/ \__, | \/ \/ \__,_|\__\___|_|
timeout 1 > nul
echo __/ |
timeout 1 > nul
echo |___/
timeout 1 > nul
pause
you need to escape some special symbols - in your case pipes. Try like this:
echo _ _ _ _ __ __ _
timeout 1 > nul
echo ^| ^| ^| ^| ^| ^| ^| ^| \ \ / / ^| ^|
timeout 1 > nul
echo ^| ^|__^| ^| ___ ^| ^|_ __^| ^| ___ __ _ \ \ /\ / /_ _^| ^|_ ___ _ __
timeout 1 > nul
echo ^| __ ^|/ _ \^| __/ _` ^|/ _ \ / _` ^| \ \/ \/ / _` ^| __/ _ \ '__^|
timeout 1 > nul
echo ^| ^| ^| ^| (_) ^| ^|^| (_^| ^| (_) ^| (_^| ^| \ /\ / (_^| ^| ^|^| __/ ^|
timeout 1 > nul
echo ^|_^| ^|_^|\___/ \__\__,_^|\___/ \__, ^| \/ \/ \__,_^|\__\___^|_^|
timeout 1 > nul
echo __/ ^|
timeout 1 > nul
echo ^|___/
timeout 1 > nul
pause
Pipe expects a commands on both of its sides and will output from the first command to the second. And so cmd tries to executes them - if the executed command fails (e.g. _
) the whole script will exit. To escape the special characters use carret - ^