[lug] linux/tcsh question
Tkil
tkil at scrye.com
Tue Apr 2 11:46:24 MST 2002
>>>>> "Keith" == Keith Herold <Herold at Colorado.EDU> writes:
Keith> Well, I tried your tests and redirecting just files is fine
so it looks like redirection is working fine, and you have to stare at
your program to figure out why it isn't behaving as you expect.
Keith> (although I got a 'file 'foo'' does not exist using rpm; I
Keith> replaced foo with every shell name I could think of),
uh, what?
my "rpm" command was only to show the version of tcsh that i was using
on the linux box. note that i used backticks around the phrase "which
tcsh". this means "execute this, then put the output from this
command in the place of this backquoted phrase". what i was asking,
in full, was "find out which tcsh executable i'm using, then ask rpm
which package it came in." like so:
| $ which tcsh
| /bin/tcsh
| $ rpm -qf /bin/tcsh
| tcsh-6.10-6
the backticks just let me skip a step. see the bash info pages for
more details, particularly the node "(bash)Command Substitution".
Keith> It doesn't seem like the program is working at all when I
Keith> redirect the output, since I ran one in the background and then
Keith> ran top; the program name doesn't show up. I also ran ps -aux
Keith> and it keeps reading 0:00 for TIME.
if it's in "ps -aux" then that means it did get launched, it just
hasn't had anything to do yet. which is usually a sign of blocking,
yes. (remember that top will only show the top CPU [or memory] hogs;
it's not guaranteed to show all processes -- although i've used
implementations which allow you to "freeze" and then page through them
all....)
Keith> Why should redirection cause the problem? If I don't try to
Keith> redirect, it all runs perfectly (I don't ever have input from
Keith> stdin).
i think that DS nailed this one -- it looks like it's just using large
buffers. (generally, stdout to a terminal will be line buffered,
while stdout to a pipe or file will be block [typically 4096]
buffered.) so, even if you normally get data back quickly, the file
size won't reflect it until it has enough to flush the buffers.
you can flush them manually if you like. in C, look at the "fflush"
library call. in perl, investigate the $| special variable
finally, even if you're redirecting stdout, you can still send stuff
to stderr (with fprintf(stderr, "...", ...)) -- that stuff should
still show up (and is a very helpful debugging aid!)
t.
More information about the LUG
mailing list