|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
I found some website which explained how I can redirect both standard error and standard output to a file. However, it's not working. I get this error:
java Program.java >& out ksh: out: bad file unit number What does this mean? |
|
#2
|
||||
|
||||
|
I think you want to do this...
javaprogram 1> /outputfile 2> /errorfile This causes the output to go into /outputfile and the errors to go into /errorfile. If you want them both to go to the same place... javaprog 2>&1 which means to send the errors to the same place the output is going. |
|
#3
|
|||
|
|||
|
Quote:
Doing java prog 1> /output 2> /error ksh: /output: cannot create java prog 2>&1 print everything to the screen java prog 2>&1 out prints output to the output file, but error to the screen java prog 2>1 out prints output to the output file, but error to the screen |
|
#4
|
||||
|
||||
|
>> java prog 1> /output 2> /error
>> ksh: /output: cannot create He he... I didn't mean to literally use these... they were just examples. Like a "real" example might be... javaprog 1> /var/log/messages 2> /var/log/javaerrors Of course you'd need to create the file /var/log/javaerrors. >> java prog 2>&1 >> print everything to the screen As I said before, this will direct all errors (signified by the 2) to wherever the output is going. If your output goes to the screen, then so will the errors. More likely you want to use the first example above where you direct output and errors to different locations. Or you can do it like this... javaprog > /var/log/javaprog 2>&1 which I believe will send both to the same file located in /var/log/javaprog. REF: http://www.rospa.ca/documents/bitesized/redirection.html |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Unable to redirect error output to a file - bad file unit number |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|