[K12OSN] some scripting help

Nils Breunese nils at breun.nl
Sat May 12 13:50:33 UTC 2007


Ray Garza wrote:

> Ok I got my script working but I want to suppress a warning that is a result 
> of a "For Loop". Here is the line of code in question:
> 
> for filename in 'ls /home/$account/.mozilla/firefox/*.default/cache';do
> 
> It works fine but it kicks out an error if the cache does not exist (such as 
> new user that hasn't surfed the Internet yet).

I'd say the error message is not the result of the for loop, but of the
ls statement. You could suppress the error by redirecting standard error
to /dev/null:

    ls /home/$account/.mozilla/firefox/*.default/cache 2>/dev/null

> I plan to run it as a cron job 
> but I don't want the error messages popping up on the screen. Is there a way 
> to suppress the error message? Will putting it in a cron job log the error 
> but not display it?

I believe by default any output generated by cron jobs is mailed to the
user the script runs as. You can override the address by setting MAILTO=
in the crontab. You can also redirect all output of the cron job to
/dev/null:

    /path/to/script >/dev/null 2>&1

You can find more information on I/O redirection here:
<http://tldp.org/LDP/abs/html/io-redirection.html>

Nils Breunese.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/k12osn/attachments/20070512/97952c96/attachment.sig>


More information about the K12OSN mailing list