Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with `pause` command when redirecting a command-line log to file

Let's say we execute a command as below and redirect the console output into text file.

My issue is that there is pause commands within the batch script and when redirecting like this, I cannot know when to hit enter to continue the batch.

Please help me to get the batch "ignores" the pause commands without changing the batch itself. I prefer to get some redirect/pipe syntax.

MyBatchScriptWithPause.bat > SomeFile.txt
like image 334
Nam G VU Avatar asked Jun 17 '11 11:06

Nam G VU


2 Answers

This should do it:

 (echo.&echo.&echo.&echo.) | MyBatchScriptWithPause.bat > somefile.txt

assuming that no other command is expecting user input in that batch file.

Edit
It also assumes that only a single pause command is in that file. Otherwise Andriy's suggestion should work.

like image 124
a_horse_with_no_name Avatar answered Oct 02 '22 16:10

a_horse_with_no_name


MyBatchScriptWithPause.bat > SomeFile.txt < nul

nul is a DOS device that will provide infinite null data, so it will act as input whenever the script needs some. It is still available even on modern Windows versions.

like image 26
mrb Avatar answered Oct 02 '22 16:10

mrb