Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use output redirections from a cmd file using start?

I want to have a cmd file with something like:

:one
start /wait (blabla1.exe -q -m 1>blabla1.log 2>&1)

:two
start /wait (blabla2.exe -q -m 1>blabla2.log 2>&1)

where I want the output of the blabla application not the output of the start command.

Is it even possible to have the redirections "local" inside the start command?

Do I have to create a 1 line cmd containing
blabla1.exe -q -m 1>blabla1.log 2>&1
and pass it to the start command?

Update: I need the first one (blabla1.exe) to be finished before I launch the 2nd one (blabla2.exe). That's the reason for using start /wait.

(Windows XP and up)

like image 429
Francesca Avatar asked Aug 04 '10 01:08

Francesca


People also ask

How do you redirect output of command?

The output of a process can be redirected to a file by typing the command followed by the output redirection operator and file name. When the notation > > filename is added to the end of a command, the output of the command is appended to the specified file name, rather than writing over any existing data.

How do I redirect the output of a command in command prompt?

To redirect the output of a command to a file, type the command, specify the > or the >> operator, and then provide the path to a file you want to the output redirected to. For example, the ls command lists the files and folders in the current directory.

How do I redirect echo output to a file?

$ echo “Hello” > hello. txt The > command redirects the standard output to a file. Here, “Hello” is entered as the standard input, and is then redirected to the file **… $ cat deserts.


2 Answers

Yes it is possible to redirect output using start wait command using the /B switch.

start /B /wait myprog.exe >> output.log

If you need to break in you will have to use Ctrl+Break, Ctrl+C will be ignored. Hope this helps.

like image 85
Benjamin McGill Avatar answered Sep 19 '22 15:09

Benjamin McGill


Given that you are redirecting output to a file, and waiting for the process to finish, is the extra window started by 'start' actually required? In fact, if there WAS some way to redirect the output when using start, then the windows that popped up wouldn't even have any output...making them even more meaningless.

If not, simply remove the "start /wait" and call the exes directly.

If it IS necessary...then I'm not sure.

UPDATE: I am fairly certain just removing the "start /wait" will produce the behavior you desire. See below:

(Create the following batch file: foo.cmd

:one
notepad.exe
:two
dir

Note that dir will not echo until you close notepad.

like image 42
Joshua McKinnon Avatar answered Sep 19 '22 15:09

Joshua McKinnon