Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 19th, 2005, 10:08 AM   #1
jolok
Newbie
 
jolok's Avatar
 
Join Date: Apr 2005
Location: Antioch, TN
Posts: 3
Rep Power: 0 jolok is on a distinguished road
Send a message via MSN to jolok Send a message via Yahoo to jolok
csh suppress output; newbie question

This is a simple question, but it's giving me problems...


I have:
if( -e $HOME/*.core ) then
    rm -f $HOME/*.core &> /dev/null
  else
    echo "No core file"
endif
When I run the script I get: /home/<user>/*.core: no match

How can I suppress the output from the rm command? Thanks in advance.

Last edited by jolok; Apr 19th, 2005 at 2:42 PM.
jolok is offline   Reply With Quote
Old Apr 19th, 2005, 3:07 PM   #2
spydoor
Programmer
 
Join Date: Feb 2005
Posts: 64
Rep Power: 4 spydoor is on a distinguished road
redirect STDERR

apparently in csh there is no standard way to do it, but there are ways..

http://www.codecomments.com/Unix_Pro...age452517.html

Last edited by spydoor; Apr 19th, 2005 at 3:28 PM.
spydoor is offline   Reply With Quote
Old Apr 19th, 2005, 3:24 PM   #3
jolok
Newbie
 
jolok's Avatar
 
Join Date: Apr 2005
Location: Antioch, TN
Posts: 3
Rep Power: 0 jolok is on a distinguished road
Send a message via MSN to jolok Send a message via Yahoo to jolok
I should've mentioned that I tried that, first.

if( -e $HOME/*.core ) then
    rm -f $HOME/*.core 2> /dev/null
  else
    echo "No core file"
endif

/home/<user>/*.core: no match

And, from man rm(1):
-f Attempt to remove the files without prompting for confirma-
tion, regardless of the file's permissions. If the file does
not exist, do not display a diagnostic message or modify the
exit status to reflect an error. The -f option overrides any
previous -i options.

So it shouldn't echo stderr anyway, should it?

Also, redirecting both stderr and stdout (which I was trying to do incorrectly in the first example) doesn't help, either:

if( -e $HOME/*.core ) then
    rm -f $HOME/*.core >& /dev/null
  else
    echo "No core files to delete"
endif

the 'else' never gets a chance...

I'll try again without any redirection...
No dice. Same result. Also, from the command line (csh) rm displays the same behavior.
JoloK

Last edited by jolok; Apr 19th, 2005 at 4:00 PM.
jolok is offline   Reply With Quote
Old Apr 19th, 2005, 3:33 PM   #4
spydoor
Programmer
 
Join Date: Feb 2005
Posts: 64
Rep Power: 4 spydoor is on a distinguished road
sorry, I was thinking ksh.

I editied my post what you want is, >&

also yes, It looks like with -f there should be no error msg to worry about.

Maybe I should've left this one to someone with more knowledge......
spydoor is offline   Reply With Quote
Old Apr 19th, 2005, 3:45 PM   #5
spydoor
Programmer
 
Join Date: Feb 2005
Posts: 64
Rep Power: 4 spydoor is on a distinguished road
Okay the -f does suppress the error message.

The
/home/<user>/*.core: no match
is actually coming from your

(-e $HOME/*.core)
statement
spydoor is offline   Reply With Quote
Old Apr 19th, 2005, 4:01 PM   #6
jolok
Newbie
 
jolok's Avatar
 
Join Date: Apr 2005
Location: Antioch, TN
Posts: 3
Rep Power: 0 jolok is on a distinguished road
Send a message via MSN to jolok Send a message via Yahoo to jolok
Ah! Ok, I was orginally trying different test variables there... I'll work on it from that angle. Thanks, spydoor!


JoloK
jolok is offline   Reply With Quote
Old Apr 19th, 2005, 4:16 PM   #7
spydoor
Programmer
 
Join Date: Feb 2005
Posts: 64
Rep Power: 4 spydoor is on a distinguished road
Here's a nasty solution.... There must be much better ways

count the number of files that match *.core... ignore 'No match'...
(to be correct you would also have to ignore other find error msgs like Permission denied.....)

if(`find $HOME/*.core |& grep -v 'No match' | wc -l`) then
    echo found some
  else
    echo didn\'t find any
endif
spydoor is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:30 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC