Tcsh: How to suppress error messages.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Tcsh: How to suppress error messages.
# 1  
Old 09-24-2014
Tcsh: How to suppress error messages.

Hallo,

I wrote some script:

95% of the script's output consists of error messages like "mkdir: cannot create directory ‘final': File exists
Exit 1" and "rm: No match. Exit 1".

These messages are not harmful at all, but they make the output almost unreadable.

How can I get rid of these messages to make the output readable?

Best regards,
Daniel
# 2  
Old 09-24-2014
This is the terrible error handler.
It emergency-exits on built-in commands.
For the external command rm you can try to redirect stderr (and stdout) with
Code:
rm ... >& /dev/null


Last edited by MadeInGermany; 09-24-2014 at 05:44 PM.. Reason: typo
This User Gave Thanks to MadeInGermany For This Post:
# 3  
Old 09-24-2014
From the tcsh manpage:
Code:
       The  shell  cannot  presently  redirect  diagnostic output without also
       redirecting standard output, but `(command  >  output-file)  >&  error-
       file'  is often an acceptable workaround.  Either output-file or error-
       file may be `/dev/tty' to send output to the terminal.

Thus you could try following:
Code:
( yourscript > /dev/tty ) >& /dev/null

This User Gave Thanks to junior-helper For This Post:
# 4  
Old 09-24-2014
Both methods reduce the number of messages.
There are still a couple of "Exit 1" messages.

DanielDD
# 5  
Old 09-24-2014
Your tcsh script seems to have printexitvalue set, maybe set in your ~/.cshrc or ~/.tcshrc.
Undo with
Code:
unset printexitvalue

You can suppress the initial run of .cshrc and .tcshrc by a -f option in the shebang (first line)
Code:
#!/bin/tcsh -f

This User Gave Thanks to MadeInGermany For This Post:
# 6  
Old 09-24-2014
It works, thanks alot.

Daniel
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to suppress error in following command?

I have a file containing data in multiple columns. The colums are seperated by pipe (|). I need to extract information as below: myfile_20130929_781;10;100.00 where myfile.txt is the file name. 10 is the number of records in the file starting with 120 and 100.00 is the sum of 26th field of... (16 Replies)
Discussion started by: angshuman
16 Replies

2. Shell Programming and Scripting

Suppress Error Message

How can I suppress a error message being given by awk command in bash shell? (2 Replies)
Discussion started by: Prachi Gupta
2 Replies

3. UNIX for Dummies Questions & Answers

suppress RCS messages

ci filename This command displays a message. I don't want it to. How can I keep RCS from doing so? (5 Replies)
Discussion started by: robin_simple
5 Replies

4. UNIX for Dummies Questions & Answers

pine email tool suppress prompt to save read messages

Could somebody please advise about how to configure pine/alpine so that on exit it doesn't prompt me to save read messages? Thanks (3 Replies)
Discussion started by: LeoKSimon
3 Replies

5. Shell Programming and Scripting

How to suppress the error while copying the file

HI , I am tryin to copying multiple files from some dir. If the files are not present. It should not throw error in the screen. HOw to do that . Please help (4 Replies)
Discussion started by: arukuku
4 Replies

6. Shell Programming and Scripting

Suppress error message in shell script

Hi All this is a simple script #! /bin/bash FileCnt=`ls -lrt $DIR/* | wc -l` echo $FileCnt how could i escape the error msg if there are no files in $DIR ls: /home/sayantan/test/files/cnt/*: No such file or directory 0 Looking forward for a quick reply Regards, Newbie... (3 Replies)
Discussion started by: newbie07
3 Replies

7. Shell Programming and Scripting

Suppress error message in unzip

I'm creating a bsh shell to unzip a file from one directory into another. The directory that holds the zip files has zip files constantly being added to it, so I am testing it before it does the unzip and more. Right now my code looks like this: unzip -tq $ZIP_PATH/$ZIP_NAME >/dev/null if ... (5 Replies)
Discussion started by: skwyer
5 Replies

8. Shell Programming and Scripting

How to suppress error messages in script

I am getting the following upon cat a file which is not present in directory. "cat: cannot open test1.txt" I need to process files and I want that this message should be suppressed. thx (5 Replies)
Discussion started by: helper2007
5 Replies
Login or Register to Ask a Question