1.

Solve : A little help with batch?

Answer»

copy con is an old command that usually used to create a file.
whatever you type in the console will be echoed back to std-out.
therefore you use 'copy con>out.txt', to redirect the std-out to a file.
then to end press CTRL-Z.

but if you are refering to CON(SOLE).
if you do this
type nul>test.txt 3>&1
you will lose the command prompt, whatever command you type, the console output will be redirected to file 'test.txt'
the '3' REFER to console, but i can't FIND any good use for it.con is both an input, and output device. in the context of "copy con File" it is an input device. Therefore it copies the standard input to the file until Ctrl-Z, or EOF, is pressed.

copy con will copy a file to the screen. the output cannot be piped, since the output isn't on stdout but rather directly to the output console, the screen.



the numbers 1 through 3 are actually valid filehandles, and represent the standard Input, output, and error streams.Quote from: BC_Programmer on June 03, 2009, 04:59:09 PM

copy <file> con will copy a file to the screen. the output cannot be piped, since the output isn't on stdout but rather directly to the output console, the screen.
copy con - copy from file to console, great, i never the syntax exist. for clarification, i usually use 'copy con file', not 'copy con>file', a mistake i made in the above post.
now if only type 'copy con', whatever i type+enter is displayed twice, so i believe the extra echoed string is save into file when using 'copy con file'

Quote from: BC_Programmer on June 03, 2009, 04:59:09 PM
the numbers 1 through 3 are actually valid filehandles, and represent the standard Input, output, and error streams.
i agree it's actual file handles in windows.

but in nt batch, i am sticking with this until i am PROVEN wrong:
1> std-out
2> std-err
3> console
not sure about std-in represent what number.CON represents both stdin and stdout- it DEPENDS on the context.

for example, copy con would be stdin, since it's reading from con. copy con would be stdout, since it's WRITING to the console.


Discussion

No Comment Found