Home > Blockchain >  Redirect the output outside the output file
Redirect the output outside the output file

Time:01-04

I have a batch which call another batch file. Lets call them b1 and b2. Here is the code inside my 2 batch files.

b1 :

@echo off

call b2.cmd 1>output.txt

and b2 :

@echo off

echo "I want this in output.txt"
echo "I want this in the cmd window" 1>&1

After executing my script I got :

output.txt :

"I want this in output.txt"

and in the command line :

The handle couldn't be duplicated during the redirection of the handle 1.

(which is : "Le handle n’a pas pu être dupliqué lors de la redirection du handle 1." in french, (and sry for the bad traduction))

And I want to have :

output.txt :

"I want this in output.txt"

and in the command line :

"I want this in the cmd window"

Do someone have any idea to make this output ?

If you need any details, ask me and I will try to help you.

PS : I can have more than 1 intermediate file (like b1 call b2, b2 call b3, etc) and I still want to print something from the last file.

CodePudding user response:

echo "I want this in the cmd window" 1>con

worked for me.

  • Related