Re: redirecting stdin and stdout to a file



On 27 Sep 2006 02:32:02 -0700, robannexs@xxxxxxxxx wrote:
hi,
i've been trying to redirect stderr and stdout to a file,

i ran these command,

dd if=/dev/null of=/dev/null &pid=$!
kill -USR1 $pid > abc.txt 2>&1

somehow i still manage to get the output on screen;
19755503+0 records out
10114817536 bytes (10 GB) copied, 122.91 seconds, 82.3 MB/s

i have also tried directing only the stdout to a file, and only stderr
to a file, with both bearing similar results as above. why is it so? is
there somethign else that will print to screen other than these 2?
[...]

You're redirecting kill's standard output and standard error to
abc.txt, not dd's. Kill doesn't output anything (except maybe
for some error messages when it doesn't manage to send a signal
to another process)

And it's strange that dd would manage to read something from
/dev/null (wasn't it if=/dev/zero?).

dd if=/dev/zero of=/dev/null 2> abc.txt &
kill -USR1 "$!"


{
(
trap : INT # revert the ignoring of SIGINT by the shell
# (sigh) for CTRL-C handling
exec dd if=/dev/zero of=/dev/null 2>&1
) &
echo "$!"
} | {
read pid &&
while sleep 1; do
kill -USR1 "$pid"
read discard &&
read discard &&
read bytes discard || break
echo "$bytes bytes copied so far"
done
}

--
Stephane
.



Relevant Pages

  • Re: redirecting stdin and stdout to a file
    ... i've been trying to redirect stderr and stdout to a file, ... i have also tried directing only the stdout to a file, ... You are redirecting the output of the 'kill' command. ...
    (comp.unix.shell)
  • Re: using subprocess for non-terminating command
    ... read through PIPE's stdout it seems. ... Then you can decide to kill the subprocess when you have enough data, ... The pexpect faq talks a little bit about ...
    (comp.lang.python)
  • Re: Runtime exec problems with process with multiple args
    ... it's STDOUT and will halt until somebody reads it. ... to read the STDERR and STDOUT from your process. ... > Failed Solution 1: ... > seems to kill the cmd.exe but the sub-sub process ...
    (comp.lang.java.programmer)
  • Re: How can I read help from executables ?
    ... Redirect stderr to stdout: ... Does mp3blaster not have a man page? ... bugs. ... former should go to stdout and the latter to stderr. ...
    (alt.linux)
  • Re: How can I read help from executables ?
    ... and it just prints the whole manual, I cant see the first options ... but still it wizzes past ... The program probably sends its help to stderr instead of stdout. ... Redirect stderr to stdout: ...
    (alt.linux)