![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| comparing strings in seperate files | orahi001 | UNIX for Dummies Questions & Answers | 2 | 03-27-2008 12:04 PM |
| where are my email log files | mstarcom | UNIX for Dummies Questions & Answers | 3 | 11-28-2007 06:39 PM |
| Split File into seperate files | eltinator | Shell Programming and Scripting | 4 | 08-03-2007 03:27 PM |
| How do I stop printf output from going into seperate txt files | chrchcol | Shell Programming and Scripting | 12 | 07-26-2006 10:08 PM |
| Email files with files - wild character | bobo | UNIX for Dummies Questions & Answers | 4 | 01-16-2006 10:07 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Email like files in seperate emails
My goal is to send multiple files to a person based on their input. The files have similar names like: Code:
file1-egress-filter file2-ingress-filter stuff1-egress-filter stuff2-ingress-filter ... The script is run with the filename given as arguments, such as: Code:
./mail.sh file stuff would email all of the above files. The script I have currently does email all the files, but it puts each into it's own email and I would like file1 and file2 grouped and stuff1 and stuff2 grouped, etc. Here's what I have: Code:
#!/bin/bash
TFILE="/tmp/$(basename $0).$$.tmp"
> $TFILE
clear
echo "Who would you like to receive the email?"
echo "[1] Person1"
echo "[2] Person2"
echo "[3] Other"
read choice
case $choice in
1) email="person1@place.com" ;;
2) email="person2@place.com" ;;
3) echo -n "What email address would you like to send the files to? " ; read email
esac
array=( $* )
clear
for file in ${array[@]:0}
do
ls $file*-filter >> $TFILE
done
files=`cat $TFILE`
for file in $files
do
cp $file "$file".txt
echo "Mailing" "$file".txt
mutt -s "$file" -a "$file".txt $email \
< /dev/null
rm "$file".txt
done
rm $TFILE
I think that should be pretty easy to read through, but if there is a better way to go about that portion, I'd be very happy to learn a better way. As stated above, my main question is, is it possible to differentiate between file1 and 2 and stuff1 and 2 to put them in different emails via multiple -a flags on the mutt line. I hope that was all coherent. Thanks for your help! |
|
||||
|
Quote:
I want one email to go out with file1 and file2 attached ( Code:
mutt -s "Files" -a file1 -a file2 $email ) and another email with stuff1 and stuff2 attached. Is it possible to make the loop differentiate? I was thinking of holding the file it just emailed in the current loop to a variable, and then test that against the next file it was going to email and if they match, put them in the same email but if not, start a new mutt line. I'm stepping a little above my head with that, and I'm not sure it's even possible. |
|
||||
|
Quote:
![]() The nested loops really ..."threw me for a loop" at first, but I echoed the var after each one and I got it now. That is very nice. I think I'm finally learning the syntax and such, I just need to develop the ability to "think outside the box" on things such as this. Anyways, thanks again. |
|
||||
|
Quote:
I don't feel safe doing rm *.txt ... ideas? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|