Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-03-2003, 10:30 AM
|
#1
|
|
LQ Newbie
Registered: Jul 2003
Posts: 4
Rep:
|
Output redirection
Hi everyone,
I am having a problem with redirecting ouput from a command line program. Usual commands > or >> do not come back with an error and the program appears to run, but doesn't complete. The output file I specify is always empty (size 0K).
I've been checking directory and file permissions, and path issues, but not coming up with any problems. Some syntax I've tried:
/usr/bin/tslg > /usr/bin/test
/usr/bin/tslg > test
tslg > test
/usr/bin/tslg >> test
Can anyone give me any ideas of what might cause this?
Thanks!
|
|
|
|
07-03-2003, 11:02 AM
|
#2
|
|
LQ Newbie
Registered: Mar 2003
Location: TX
Distribution: SuSE/RedHat
Posts: 5
Rep:
|
Yikes! :O "test" is a shell command, and /usr/bin/test is the program it calls. I would use a different output file name first, like tslg.out or something. You may have overwritten a fundamental shell command!!!
If you still don't get output in your file-with-a-new-name, does your proggie produce output on the screen when run without redirection? If so, it may be sending output to the standard error stream (stderr in C/C++). Try adding "2>&1" to your command (without the quotes) which will redirect stderr to standard out, which will then go to your file.
HTH
pilgrim22
|
|
|
|
07-03-2003, 11:34 AM
|
#3
|
|
LQ Newbie
Registered: Jul 2003
Posts: 4
Original Poster
Rep:
|
Yikes is right, I regularly use 'test' for file names! Thanks for that.
I am now using 'new'. :-) But still no output. If I remove the redirection my command works perfectly and sends 5 lines of output to the screen. After some more experimenting, I believe there is something unique to this program that is preventing the output from being redirected. The command
tslg | wc results in 0 0 0
and
tslg | less results in END
I'm planning to talk to the programmer who wrote 'tslg' but of course, he is gone for the week.
Ever seen something like this before?
Thanks again!
|
|
|
|
07-03-2003, 02:37 PM
|
#4
|
|
Member
Registered: Jun 2003
Location: Canada,Ontario
Distribution: Debian and Gentoo
Posts: 135
Rep:
|
using test like that is a common mistake heh i used to make that same mistake 
|
|
|
|
07-07-2003, 02:36 PM
|
#5
|
|
LQ Newbie
Registered: Jul 2003
Posts: 4
Original Poster
Rep:
|
For anyone who was following this thread...this was due to syntax in the program itself. Here is the info from the engineer who fixed the redirection problem:
I was calling _exit() at the end rather than exit(), and I'm assuming that one of the differences is that exit() flushes the output buffers, which is what seems to make the difference when piping output.
|
|
|
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:59 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|