The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem redirecting output of command to variable nunovc Shell Programming and Scripting 2 08-08-2008 12:15 PM
Adding custom mesg. when redirecting "exec 2>stderr.err" ? snurani Shell Programming and Scripting 0 07-10-2008 12:19 PM
Redirecting STDERR message to STDOUT & file at same time vikashtulsiyan Shell Programming and Scripting 10 04-09-2008 02:34 PM
Redirecting stderr while live jjinno Shell Programming and Scripting 1 10-16-2007 03:10 PM
redirecting STDOUT & STDERR jshinaman Shell Programming and Scripting 9 06-22-2007 12:04 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-27-2008
phpfreak phpfreak is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 50
Redirecting stderr problem

Code:
% ls -ld /usr /foo
ls: /foo: No such file or directory
drwxr-xr-x  14 root  wheel  512 May 18 02:49 /usr
% ls -ld /usr /foo 1>/dev/null/
/dev/null/: Not a directory.
% ls -ld /usr /foo 2>/dev/null/
/dev/null/: Not a directory.

^^Why why why doesn't this work for me. Furthermore, where is stdout on the last?

I'm trying to prevent 'find' from barfing the permission denied errors if anybody has experienced that. Wondering if I'm doing something wrong or how to further examine stderr's config on the server.

Side note: Please forgive if this answer is already posted as I've tried searching here and google with no luck. Thanks in advance for your 0.
  #2 (permalink)  
Old 08-27-2008
redoubtable redoubtable is offline
Registered User
  
 

Join Date: Aug 2008
Location: Portugal
Posts: 242
ls -ld /usr /foo 2>/dev/null without the final /
  #3 (permalink)  
Old 08-28-2008
phpfreak phpfreak is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 50
Sorry but this did't work for me..
Code:
> ls -ld /usr 
drwxr-xr-x  14 root  wheel  512 Dec 21  2007 /usr
> ls -ld /usr /foo 2>/dev/null
ls: /foo: No such file or directory
ls: 2: No such file or directory
So again, why is it that redirecting stdout works fine but not stderr? Stdout dosesn't seem to function when stderr fails?

Ls recognizes stdout but not stderr and I'm wondering how is that I can view what stderr is tagged to because to me it's obvious it's not the default '2'. Please help.
  #4 (permalink)  
Old 08-28-2008
sudhamacs sudhamacs is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 98
What is your operating system?
What does the following give?
ls -lrt /dev/null

Check if this works?
ls -ld /usr /foo 2>/directory_where_u_have_permissions_to_write/err.txt
  #5 (permalink)  
Old 08-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Either you are using a csh derivative which doesn't understand the 2> redirection, or you mistyped it. In csh the redirection syntax is different. What happened in the last case was that the regular output was redirected to /dev/null and the error messages were not.
  #6 (permalink)  
Old 08-28-2008
phpfreak phpfreak is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 50
Thanks ppl for the quick reply.

Sudhamacs, you answered before I got a chance to post the version but here is the information you requested..
Code:
je# uname -srp
FreeBSD 6.2-RELEASE i386
je#
Don't think that permissions is the issue here since ls isn't recognizing '2' as a valid operator. Hence ls with the d switch will fail.

Another note i should add is that when i hit up (history) i find that the system executes with a space.

ls -ld /usr /foo 1>/dev/null/
.. works on they system as ..
ls -ld /usr /foo 1 > /dev/null/

^^Not sure if this is relevant or not. Also, here's some additional information..


Code:
je# ls -l /dev/null
crw-rw-rw-  1 root  wheel    0,   6 Aug 28 14:35 /dev/null
je# ls -l /dev/st* /dev/fd
lrwxr-xr-x  1 root  wheel  4 Dec 31  1969 /dev/stderr -> fd/2
lrwxr-xr-x  1 root  wheel  4 Dec 31  1969 /dev/stdin -> fd/0
lrwxr-xr-x  1 root  wheel  4 Dec 31  1969 /dev/stdout -> fd/1

/dev/fd:
total 0
crw-rw-rw-  1 root  wheel    0,  18 Jul 27 21:37 0
crw-rw-rw-  1 root  wheel    0,  20 Jul 27 21:37 1
crw-rw-rw-  1 root  wheel    0,  22 Jul 27 21:37 2
je#

Last edited by phpfreak; 08-28-2008 at 03:03 PM..
  #7 (permalink)  
Old 08-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
The % prompt is often indicative of csh, what does echo $SHELL say?
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0