I'm trying to run multiple commands in Windows cmd. And need to sleep for ~4 seconds between the commands.
I copy my commands block to the cmd and then want them to run one after the other with breaks of 4 seconds.
My problem is that the timeout command stops the execution and not continue to the next commands:
python3 my_file.py -a
timeout /t 4 /nobreak > nul
python3 my_file.py -b
timeout /t 4 /nobreak > nul
python3 my_file.py -c
The first and the second lines are running and then it ends and shows the >
sign.
(I did the same thing in Linux with the 'sleep' command ant it works perfect)
I also tried different options of the timeout command such as timeout /t 4
and timeout 4
but nothing works...
How can I do it? it must run on Windows cmd and not as batch file.
Thanks
Update:
As @JosefZ answered, my problem caused by the PASTE usage. The timeout command ignored the PASTE command, so I didn't get the next commands.
Using the PING command as his answer solved the issue.
timeout /?
says about the /NOBREAK
parameter:
/NOBREAK
Ignore key presses and wait specified time.
Ignore, i.e. choke down all content of keyboard buffer filled by a PASTE technique.
A delay can also be produced by the
PING
command with a loopback address (127.0.0.1
), in tests this consumes less processor time thanSleep.exe
orTimeout.exe
. The delay between each ping is 1 second, so for a delay of 5 seconds ping 6 times.
The following code snippet should work as expected:
python3 my_file.py -a
PING -n 5 127.0.0.1 1>nul 2>&1
python3 my_file.py -b
PING -n 5 127.0.0.1 1>nul 2>&1
python3 my_file.py -c