Redirecting STDOUT
Dan Busarow
dan at dpcsys.com
Fri Dec 21 11:05:08 PST 2007
On Dec 21, 2007, at 10:34 AM, jhall at vandaliamo.net wrote:
>
>> In that case you only redirecting STDERR to file. As you've been
>> already told STDOUT will be redirected with
>>
>> $ command 1>file
>>
>> or
>>
>> $ command > file
>>
>> adding 2>&1 will also redirect STDERR to this file
>>
>
> When I run this as a non-root user it works fine. But, when
> running it as
> root, it does not produce the expected results.
>
> $ ls -l /fjdkslafjdl 2>/home/hallja/test2
> And, in the file test2, I see
>
> ls: /fjdkslafjdl: No such file or directory
>
> Running the same command as root, I receive the following results.
> # ls -l /fjdkslafjdl 2>/home/hallja/test2
> ls: /fjdkslafjdl: No such file or directory
>
> And, in /home/hallja/test2 I see the following.
> -rw-r--r-- 1 root hallja 0 Dec 21 08:02 2
>
> Why does this not work as root?
>
When you are root type in
# echo $SHELL
Unless you previously invoked /bin/sh
# sh
you are almost certainly running csh
Dan
More information about the freebsd-questions
mailing list