UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old October 20th, 2004, 03:22 PM
smiles78 smiles78 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 46 smiles78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 33 sec
Reputation Power: 5
Unhappy Unable to redirect error output to a file - bad file unit number

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?

Reply With Quote
  #2  
Old October 21st, 2004, 08:13 AM
Donboy's Avatar
Donboy Donboy is offline
The Evil Monkey
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 220 Donboy User rank is Private First Class (20 - 50 Reputation Level)Donboy User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 38 m 10 sec
Reputation Power: 6
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.

Reply With Quote
  #3  
Old October 21st, 2004, 09:12 AM
smiles78 smiles78 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 46 smiles78 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 33 sec
Reputation Power: 5
Exclamation

Quote:
Originally Posted by Donboy
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.


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

Reply With Quote
  #4  
Old October 21st, 2004, 09:40 AM
Donboy's Avatar
Donboy Donboy is offline
The Evil Monkey
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 220 Donboy User rank is Private First Class (20 - 50 Reputation Level)Donboy User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 38 m 10 sec
Reputation Power: 6
>> 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

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Unable to redirect error output to a file - bad file unit number


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway