Sponsored Content
Top Forums Shell Programming and Scripting Loop multiple directory, find a file and send email Post 302959385 by penchev on Monday 2nd of November 2015 04:25:21 AM
Old 11-02-2015
Loop multiple directory, find a file and send email

Hello ALL,

need a BASH script who find file and send email with attachment.
I have 50 folders without sub directories in each generated files of different sizes but with a similar name Rp01.txt Rp02.txt Rp03.txt ...etc. Each directors bound by mail group, I need a script that goes as directories and detect file sending mail attachment of the email group.

example


/home/test/test01
/home/test/test02
/home/test/test03
/home/test/test04
/home/test/........
/home/test/test50

/home/test/test01 = test01@example.com
/home/test/test02 = test02@example.com
/home/test/test03 = test03@example.com
......
/home/test/test50 = test50@example.com


script : when find file in directory test01 --> auto send mail with attachment file to test01@example.com




I hope I described things well, sorry for bad English

Code:
mutt -s "Subject" -a $(find /home/test/test01 -type f -name "Rp*.txt") -- test01@example.com < /dev/null

if use above line "mutt..." when i need a 50 rows crontab Smilie

Last edited by penchev; 11-02-2015 at 10:58 AM.. Reason: code tags please
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using mailx to send email to multiple users.

Hi, I am using the mailx command to send email to multple users. The command works fine when i am sending mail to a single user but when i insert multiple email ids inside the quote it does not work. All the email ids are coming from a property file.Please have a lookt at the property file and... (4 Replies)
Discussion started by: priyaksingh
4 Replies

2. UNIX for Dummies Questions & Answers

to send email to multiple users

hi, i'm pretty new to this unix. i've been asked to create a shell script which will pick up the email id from a text file(stored in same machine, same directory) searches for that id in another file in which a product name( a one line text) is mentioned against it. then it should send a mail... (0 Replies)
Discussion started by: vishwas.shenoy
0 Replies

3. Shell Programming and Scripting

Shell script: If a file stays in a particular directory more than 30 min send an email

Hi , I am new to shell scripting. i have a requirement say i will receive a file in a directory say /xyz.if that file stays in that directory more than 30 min i need to get a mail to my outlook.this should run for every 20 min in crontab. can anyone help me? (8 Replies)
Discussion started by: muraliinfy04
8 Replies

4. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

5. Shell Programming and Scripting

Grep multiple instances and send email.

Removed (15 Replies)
Discussion started by: saisneha
15 Replies

6. Shell Programming and Scripting

How to send email with multiple attachments ?

Hello , I am trying to send an email with two attachments . I have tried all previous suggestion in this forum but none worked. I could send one attachment in an email by uuencode $file "$file" | mailx -m -s "File" xxx@xx.com but unable to send multiple attachments . I have tried ... (8 Replies)
Discussion started by: RaviTej
8 Replies

7. Shell Programming and Scripting

how to find a pattern from an external file in a directory containing multiple file recursively

Hi, Need your help in this. I have an input file that has multiple enrollment_number, somewhat like 1234567 8901234 9856321 6732187 7623465 Now i have to search and delete these enrollment_number recursively from all the files that are within multiple sub-directories of a... (10 Replies)
Discussion started by: mukulverma2408
10 Replies

8. Shell Programming and Scripting

Send email if latest file in a directory is older than 2 hours

I have a objective of Sending email if latest file in a directory(excluding files of sub-dirs) is older than 2 hours. eg : ls -ltr drwx--x--x 2 abcde abc 256 2017-02-07 20:10 Mail -rw-rw-r-- 1 abcde abc 1170 2017-02-24 17:30 test -rw-rw-r-- 1 abcde abc 356 2017-03-09 18:00 xyz.csv... (3 Replies)
Discussion started by: simpltyansh
3 Replies

9. Shell Programming and Scripting

Loop to execute 2 times and send an email alert

After the successful start of server, it should check the status again, if it is not running ,it should go through the loop for 2 times. Even after two times of execution if still the server is not running it should send an alert email. Please help (1 Reply)
Discussion started by: thomas9192
1 Replies

10. Shell Programming and Scripting

Send an email if "No such file or directory" in the shell script program log in EBS concur

Hi All, I have the below code(.sh) and need to send an email. #!/bin/bash cp /u02/xxc_incoming/TEST*.dat /u02/xxc_archive_incoming/AMER7764_ARPP_2/ cat /u02/xxc_incoming/TEST*.dat > /u02/xxc_incoming/XXC_TEST.dat rm /u02/xxc_incoming/TEST*.dat cd $XXC_TOP/bin sqlldr userid=apps/<pwd> ... (12 Replies)
Discussion started by: Mist123
12 Replies
IWATCH(1)						      General Commands Manual							 IWATCH(1)

NAME
iwatch - a realtime filesystem monitor / monitor any changes in directories/files specified SYNOPSIS
iwatch [options] DESCRIPTION
This manual page documents briefly the iwatch command. iWatch is a realtime filesystem monitoring program. It's a simple perl script to monitor changes in specific directories/files and send email notification immediately. It reads the dir/file list from xml config file and needs inotify support in kernel (Linux Kernel >= 2.6.13). OPTIONS
Usage for daemon mode of iWatch: iwatch [-d] [-f <config file>] [-v] [-p <pid file>] In the daemon mode iWatch has the following options: -d Execute the application as daemon. iWatch will run in foregroud without this option. -f <configfile.xml> Specify alternative configuration file. Default is /etc/iwatch/iwatch.xml. -p <pidfile> Specify an alternate pid file (default: /var/run/iwatch.pid) -v Be verbose. Usage for command line mode of iWatch: iwatch [-c command] [-e event[,event[,..]]] [-h|--help] [-m <email address>] [-r] [-s <on|off>] [-t <filter string>] [-v] [--version] [-x exception] [-X <regex string as exception>] <target> In the command line mode iWatch has the following options: -c <command> You can specify a command to be executed if an event occurs. For details about the string format take a look at /usr/share/doc/iwatch/README.gz. -C <charset> Specify the charset (default is utf-8). -e <event[,event[,..]]> Events list. For details about possible events take a look at /usr/share/doc/iwatch/README.gz. -h, --help Print help message. -m <emailaddress> Contact point's email address. Without this option, iwatch will not send any email notification (obviously). -r Recursivity of the watched directory. -s on|off Enable or disable reports to the syslog (default is off/disabled). -t <filter> Filter string (regex) to compare with the filename or directory name. -x <exception file or directory> Specify the file or directory which should not be watched. -X <regex string as exception> Specify a regex string as exception. USAGE EXAMPLES
% iwatch /tmp Monitor changes in /tmp directory with default events. % iwatch -r -e access,create -m root@localhost -x /etc/mail /etc Monitor only access and create events in /etc directory recursively with /etc/mail as exception and send email notification to cahya@localhost. % iwatch -r -c (w;ps -ef)|mail -s '%f was changed' root@localhost /bin Monitor /bin directory recursively and execute the command. % iwatch -r -X '.svn' ~/projects Monitor ~/projects directory recursively, but exclude any .svn directories inside. This can't be done with a normal '-x' option since '-x' can only exclude the defined path. AUTHOR
iwatch was written by Cahya Wirawan <cahya@gmx.at>. This manual page was written by Michael Prokop <mika@debian.org> for the Debian project (but may be used by others). IWATCH(1)
All times are GMT -4. The time now is 07:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy