Redirecting STDOUT

Michael Lednev liettneff at bk.ru
Fri Dec 21 23:51:53 PST 2007


Hello, jhall.

On 21 ??????? 2007 ?., 20:34:52 you wrote:

jvn> When I run this as a non-root user it works fine.  But, when running it as
jvn> root, it does not produce the expected results.

jvn> $ ls -l /fjdkslafjdl 2>/home/hallja/test2
jvn> And, in the file test2, I see

jvn> ls: /fjdkslafjdl: No such file or directory

jvn> Running the same command as root, I receive the following results.
jvn> # ls -l /fjdkslafjdl 2>/home/hallja/test2
jvn> ls: /fjdkslafjdl: No such file or directory

jvn> And, in /home/hallja/test2 I see the following.
jvn> -rw-r--r--  1 root  hallja  0 Dec 21 08:02 2

jvn> Why does this not work as root?

Because default shell for root is csh. Try this

# command >& file

this will redirect both STDERR and STDOUT to file

-- 
Best regards,
 Michael                          mailto:liettneff at bk.ru



More information about the freebsd-questions mailing list