13

I'm fairly new to batch scripting but reasonably competent with programming in general. I'm currently calling a perl script from a batch file and am displaying the result from the perl script in the Windows command window for 10 seconds before exiting the command window.

I'm using the command

timeout /t 10 /nobreak

which is then also printed to the command window after the result of the perl script.

Is there any way to prevent this so that I just see the result of the perl script and then see the timer counting down?

I understand I can append '> NUL' to my timeout command to suppress the countdown timer but this isn't what I want to do. I just want to prevent what I see as a line of code printing to the command window. If this can't be done, it's no problem, I'll live with it. But if I can remove it I'd like to.

Thanks in advance for any help!

0

3 Answers 3

20

Try doing,

timeout /t 10 nobreak>nul
Sign up to request clarification or add additional context in comments.

2 Comments

From the question: I understand I can append '> NUL' to my timeout command to suppress the countdown timer but this isn't what I want to do..
For me, piping >nul to the timeout command effectively suppresses the message, e.g. Waiting for 5 seconds, press a key to continue ...43210
19

If you want to avoid echoing one command, prefix it with @:

@timeout /t 10 /nobreak

You can disable echoing at all with command

echo off

Normally, you put

@echo off

at beginning of batch file, so commands are not outputed.

2 Comments

Despite the comment here en.wikipedia.org/wiki/Batch_file#Explanation that '@ symbol at the start of any line prevents the prompt from displaying that command as it is executed', this does NOT work for Timeout. The post below by user6024091 to pipe the output to >nul DOES work however.
@DavidCarr @ prevents command echoing, not command output. >, 2> and | are used for output handling, but this not the question in this case.
1

The way i do it is like this.

::silent timeout
for /f "tokens=*" %%a in ('
timeout /t 10 /nobreak 2^>Nul
') do echo | break

a simple one liner can be timeout /t 10 /nobreak >nul

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.