Sponsored Content
Full Discussion: Please, review script.
Top Forums Shell Programming and Scripting Please, review script. Post 302256187 by algernonz on Saturday 8th of November 2008 01:08:49 PM
Old 11-08-2008
Please, review script.

Hi guys,

I 've been brewing this shellscript, but I can't test it until next tuesday.
In the meantime I am too curious wether it will work or not, so I'd like to hear your comments.

Background:
I want to watch the user quota for mailboxes in various email-domains on a IMAP-server.
I have a list of directories in which the user mailboxes reside (domains.txt). The dirnames are named after the specific email-domain.
The users' mailbox quota is at 100 MB.
So if the quota will reach 100MB or more, it is written to a report for the mailserver admin.
And an email is written to the responsable person for the email-domain.

shell=bash
OS=Debian Linux

Thanks & regards, A.



#!/bin/bash
echo " Exceeded mailbox-quota in domains" > /home/tmp/report.txt
echo "*************************************" >> /home/tmp/report.txt
#
ls /home/mailboxes > /home/tmp/domains.txt
#
while read domain; do
cd /home/mailboxes/$domain
echo "Checked mailboxes of $domain...." >> /home/tmp/report.txt
du -k --max-depth=1 | sort -rn > /tmp/$domain.f1
sed -e '1d' < /tmp/$domain.f1 > /tmp/$domain.f2
sed -e 's%./% %g' < /tmp/$domain.f2 > /tmp/$domain.userquota

while read num user; do
if [ $num -ge 100000 ] ; then
echo " $user's mailbox is $num Kb in $domain. This should be 100000" >> /home/tmp/$domain.report.txt
echo " $user's mailbox is $num Kb" >> /home/tmp/report.txt
echo " " >> /home/tmp/report.txt
echo "---------------------------" >> /home/tmp/report.txt
#
/usr/bin/mutt -nx -e 'set from=admin@mailhostingdomain.com; set realname="My RealName"' \
-s "Noreply: emailquota exceeded " -a /home/tmp/$domain.report.txt postmaster@$domain < /dev/null
else
echo " No quota have been exceeded for $domain " >> /home/tmp/report.txt
echo " " >> /home/tmp/report.txt
echo "---------------------------" >> /home/tmp/report.txt
fi

done < /tmp/$domain.userquota

done < /home/tmp/domains.txt

/bin/mv /home/tmp/report.txt /home/work/report-$(date +%F).txt
/usr/bin/mutt -nx -e 'set from=admin@mailhostingdomain.com; set realname="My RealName"' \
-s "Noreply: New emailquota report $(date + %F) " -a /home/work/report-$date +F).txt postmaster@mailhostingdomain.com < /dev/null
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Review the Shell Script

Hi, I want to copy all the log file except current date log from one server to another server. Log File will be like this LOGNIG_08_11_2008*.log For this cd /test/log date -d '1 day ago' "+%d_%m_%Y" -->This command gives previous day scp LOGSNIG_date -d '1 day ago' "+%d_%m_%Y"... (2 Replies)
Discussion started by: srinivasvandana
2 Replies

2. Shell Programming and Scripting

Review Check list for Unix Shell Script

Hi, I need Unix Shell Script Review Check list in the format of word or excel. Can any one provide the review checklist for unix shell script. Pls. (1 Reply)
Discussion started by: praka
1 Replies

3. Shell Programming and Scripting

a shell script for review.

I have written a bit of shell that lets our company check all our SSL certs. the aim is to have a list of servers and run this check from cron once a week. Our managers have decided that we will not run BASH, so it has been written in /bin/sh and only needs openssl, no perl, no bash, no extra... (8 Replies)
Discussion started by: robsonde
8 Replies

4. Shell Programming and Scripting

Please review script for search in all files

I have written a little script to scan users home directories for certain commands located inside a file. The script is setup to include a small help section and allows for passing a username argument to override scanning of all users home directories. A lot of searching and trial and error has... (7 Replies)
Discussion started by: bkeep
7 Replies

5. UNIX for Dummies Questions & Answers

Question/review my script: removing bad chars from filenames

The task: remove undesirable characters from filenames. Restrictions: Must use basic RE, base utilities (non-GNU) and /bin/sh (ash). No ksh, zsh, perl, etc. Below is what I've come up with. It seems to work OK but I'm open to shorter, more efficient alternatives. Inside the square... (4 Replies)
Discussion started by: uiop44
4 Replies

6. Shell Programming and Scripting

Please review error routines in my ksh script

The script distributes files from an AIX server using iether ftp or sftp depending on the constraint of the destination server. I am interested in having the error checking routine critically reviewed. I will only include an excerpt from the script concerning error trapping: (where $FTP_OUT is the... (7 Replies)
Discussion started by: peleton
7 Replies

7. Shell Programming and Scripting

Peer Review File/Folder Script

Hello *nix friends, I've written a shell script that allow web admin's to copy file/folder from a development site to the production site. It's more or less a poor man SVN. I'm posting the script here because I was able to get many questions answered through this forum and also, I want to... (4 Replies)
Discussion started by: rwhite35
4 Replies

8. Cybersecurity

Log Review- SU

Hi, Can some please provide some hints on what to look for in unix/Linux logs such as sulog from a Information security perspective. Regards (2 Replies)
Discussion started by: Tilus
2 Replies
avahi.service(5)						File Formats Manual						  avahi.service(5)

NAME
avahi.service - avahi-daemon static service file SYNOPSIS
/home/lennart/tmp/avahi/etc/avahi/services/*.service DESCRIPTION
/home/lennart/tmp/avahi/etc/avahi/services/*.service are XML fragments containing static DNS-SD service data. Every service file can con- tain multiple service definitions which share the same name. This is useful for publishing service data for services which implement multi- ple protocols. (i.e. a printer implementing _ipp._tcp and _printer._tcp) XML TAGS
<service-group> The document tag of avahi service files. Should contain one <name> and one or more <service> elements. <name replace-wildcards="yes|no"> The service name. If replace-wildcards is "yes", any occurence of the string "%h" will be replaced by the local host name. This can be used for service names like "Remote Terminal on %h". If replace-wildcards is not specified, defaults to "no". <service protocol="ipv4|ipv6|any"> Contains the service information for exactly one service type. Should contain one <type> and one <port> element. Optionally it may contain one <domain-name>, one <host-name>, any number of <subtype> and any number of <txt-record> elements. The attribute protocol specifies the protocol to advertise the service on. If any is used (which is the default), the service will be adver- tised on both IPv4 and IPv6. <type> Contains the DNS-SD service type for this service. e.g. "_http._tcp". <subtype> Contains an additional DNS-SD service subtype for this service. e.g. "_anon._sub._ftp._tcp". <domain-name> The domain name this service should be registered. If omited defaults to the default domain of the avahi daemon. (probably .local) <host-name> The host name of the host that provides this service. This should be a host that is resolvable by multicast or unicast DNS. Please note that you need to specify a fully-qualified domain name (FQDN) here, i.e. .local is not appended implicitly! The host name doesn't need to be part of the domain specified in <domain-name>. See avahi.hosts(5) for more information how to publish additional host name mappings. <port> The IP port number the service listens on. <txt-record> DNS-SD TXT record data. AUTHORS
The Avahi Developers <avahi (at) lists (dot) freedesktop (dot) org>; Avahi is available from http://avahi.org/ SEE ALSO
avahi-daemon(8), avahi.hosts(5) COMMENTS
This man page was written using xml2man(1) by Oliver Kurth. Manuals User avahi.service(5)
All times are GMT -4. The time now is 04:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy