Sponsored Content
Top Forums Shell Programming and Scripting Suppressing a message from being displayed Post 302471363 by vpv0002 on Friday 12th of November 2010 02:54:55 PM
Old 11-12-2010
Suppressing a message from being displayed

I have a script which checks for *.txt files in a particular directory and if no files were found then it goes into sleep for 10 secs and looks back for files again and if any files were found then the script does some processing with the files found, which is my requirement too.
Code:
FILE_EXISTS=`ls ${INPUT_DIR}/*.txt | wc -l`
if [ $FILE_EXISTS -eq 0 ];
then
echo "No file found hence sleeping for 10 secs..."
sleep 10;
continue;
fi 

but when ever no files were found a message saying
Code:
 ls: 0653-341 The file /home/sys/*.done does not exist.

Is being displayed which I do not want to be displayed. So I used
Code:
 >/dev/null 2>&1

in the script as below
Code:
FILE_EXISTS=`ls ${INPUT_DIR}/*.txt >/dev/null 2>&1 | wc -l`
if [ $FILE_EXISTS -eq 0 ];
      then
      echo "No file found hence sleeping for 10 secs..."
      sleep 10;
      continue;
fi 

now the message is not being displayed but even if files exists in the directory, the file count is not being assigned to the variable FILE_EXISTS. Doing so the script does not go further to do the required file processing but instead it still goes into sleep for 10 secs. Could any one please suggest any correction which needs to be made to my script.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

suppressing keyboard input

Setup Info: This User Id and Password mention below are being used with the ISQL command to connect to a sybase database so they are likely to not be the same as those that were signed on from the session. Situation: Using a korn shell, the shell prompts for a User Id and Password. During the... (1 Reply)
Discussion started by: anthreedhr
1 Replies

2. Shell Programming and Scripting

Suppressing one line in a file

Hello there, I am having a text file, the following is written in that text file: Full range of accounts: Account1 Account2 Account3 Account4 Now my question is. how to take that file and produce another file having only the accounts (i.e., suppressing the fist line of that... (4 Replies)
Discussion started by: charbel
4 Replies

3. UNIX for Dummies Questions & Answers

Suppressing output to the screen

I want to check whether the variable read from the console is number or character , so i used echo $option|grep and checked the reuslt returned by grep cmd using $? But since I use echo the value is getting printed in the screen , I want to supress the o/p. Can anyone suggest how this can be... (1 Reply)
Discussion started by: rolex.mp
1 Replies

4. UNIX for Dummies Questions & Answers

suppressing an error message using the "ls" command

hi I'm new here so my question maybe be retarded or out of place: Is there a way to suppress the "No such file or directory" error message when using the "ls" command ? thanks (5 Replies)
Discussion started by: basher400
5 Replies

5. Shell Programming and Scripting

Suppressing space replacing by comma

hi i want to replace spaces by comma my file is ADD 16428 170 160 3 WNPG 204 941 No 204802 ADD 16428 170 160 3 WNPG 204 941 No 204803 ADD 16428 170 160 3 WNPG 204 941 No 204804 ADD... (9 Replies)
Discussion started by: raghavendra.cse
9 Replies

6. Red Hat

Suppressing Error Message is not working

I need to suppress the error message for commands. I have given the command like below lsb_release -dr 2>/dev/null But it is not working. Am testing with Red Hat Linux release 9. Guide me. Thanks in advance (2 Replies)
Discussion started by: forumguest
2 Replies

7. Shell Programming and Scripting

Suppressing the terminated message from pkill & killall commands in a bash script

Hi all, I've been pulling my hair out with this problem for 3 days:wall: now without success any help would be massively appreciated. Basically the script is used to shutdown a rails server so a new IP address can be assigned, the shutdown part is taken care of in function_one using the... (2 Replies)
Discussion started by: danmc
2 Replies

8. Filesystems, Disks and Memory

DISK ARRAY PROTECTION SUSPENDED message displayed following disk replacement

Hello, On 4/20/2018, we performed a disk replacement on our IBM 8202 P7 server. After the disk was rebuilt, the SAS Disk Array sissas0 showed a status of degraded. However, the pdisks in the array all show a status of active. We did see a message in errpt. DISK ARRAY PROTECTION SUSPENDED. ... (1 Reply)
Discussion started by: terrya
1 Replies

9. HP-UX

Suppressing errors from command output

Hi, When I run the command "print_manifest | grep "Main Memory", I get the note : # /opt/ignite/bin/print_manifest | grep "Main Memory" NOTE: Could not read the /etc/resolv.conf file. Main Memory: 196498 MB # How do I suppress the part : NOTE: Could not read the... (4 Replies)
Discussion started by: anaigini45
4 Replies

10. UNIX for Beginners Questions & Answers

Colorful message is displayed in the terminal but not in the log file

Is there any way to print the colorful message in the terminal (which is the output of a simulation) to the log file with the same color. The colorful message at the terminal is obtained by the following codes: /////////////codes start here/////////////////////////////////////// ... (5 Replies)
Discussion started by: babunp114525
5 Replies
All times are GMT -4. The time now is 01:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy