Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Dec 2007 11:26:45 -0700
From:      Dan Busarow <dan@dpcsys.com>
To:        jhall@vandaliamo.net
Cc:        "freebsd-questions@freebsd.org - Questions" <freebsd-questions@freebsd.org>
Subject:   Re: Redirecting STDOUT
Message-ID:  <0725F14B-D147-4970-9CE2-52214D7A8BDC@dpcsys.com>
In-Reply-To: <49457.65.117.48.155.1198258492.squirrel@admintool.trueband.net>
References:  <51935.12.170.206.13.1198248568.squirrel@admintool.trueband.net> <1044977630.20071221175247@bk.ru> <49254.65.117.48.155.1198256367.squirrel@admintool.trueband.net> <863400045.20071221201413@bk.ru> <49457.65.117.48.155.1198258492.squirrel@admintool.trueband.net>

next in thread | previous in thread | raw e-mail | index | archive | help

On Dec 21, 2007, at 10:34 AM, jhall@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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0725F14B-D147-4970-9CE2-52214D7A8BDC>