• Post Reply Bookmark Topic Watch Topic
  • New Topic

2>&1 redirection  RSS feed

 
rahul dighe
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have seen the use of 2>&1 to seperate redirection of System.err and System.out. Can someone please explain me how I can achieve the following on Windows NT and UNIX
I have a programme which has two statements, one is System.out, and other System.err
i want the System.err redirected to a file and system.out to continue on the console ..
can someone tell me how do i invoke the command line for e.g.
java Test 2> out.txt ?? etc.. ?
also what does '2' '&' '1' mean ???
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Rahul,
so what you are trying to do? i'm not clear i think.
u seem to already know how to redirect the stderr to the file. then what is the question?
do u want something similar on Win NT?
as far as 2,& and 1 description is concerned,
In unix
0 = Standard input file descriptor (stdin)
1 = Standard output file descriptor (stdout)
2 = Standard error file descriptor (stderr)
when you say 2>&1 it means that stderr should be redirected to stdout. ie. all System.err.println() output gets print on Stdout.
also this might be helpful...
regards
maulin.
 
rahul dighe
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks i got my answer
i have seen the 2&1 being used for redirection, but i did not know the logic behind it, the about.com link is very useful.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!