On Tue, Nov 18, 2003 at 03:49:07PM +1100, Lyle Chapman wrote:
> I have a small script that monitors a particular folder and then 
> forwards files for printing, can anybody show me how to suppress error 
> messages and only display certain messages like "Looking for files to 
> print" and "Files found! Preparing to print" or something along those 
> lines and make it loop forever?

OK, first up, the infinite loop:

while /bin/true; do
        # ... whatever you want to do a lot of times
done

/bin/true is an incredibly simple binary which returns a true value all the
time.  Quite boring, quite useful.  You could also do something like "[ 1 =
1 ]" instead.  Basically any "conditional" which is always going to evaluate
to true will work well.

For suppressing the messages from the other commands, you can just redirect
their output to /dev/null, the Unix bit-bucket, like so:

/what/ever/command --anoption >/dev/null 2>&1

">/dev/null" points the standard output of the program to the bit bucket,
and "2>&1" says "point standard error to the place that standard output is
pointing".

You could also do ">/dev/null 2>/dev/null" which would do the same thing,
but is more keystrokes.  <g>

If you only wanted to discard error messages or other messages, you can
leave one of the parts off so those don't get discarded.  Unfortunately,
some programs use standard error for a lot of things they shouldn't, or they
print error messages to standard output.

> rm /home/user/workflow/Proofers/A4/*.pdf
> rm /home/user/workflow/Proofers/A3/*.pdf

To suppress the error message here if there's no files, you can use the -f
option to rm.

- Matt
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to