Solved

Need to attach files to email in ksh

Posted on 2009-07-09
14
512 Views
Last Modified: 2013-12-26
hi:

I need to attach two files -  .xls and .html extensions - to an email. I have the following code :

mail -s "Files for the month" tom.dick@harry.com < file1.html
How can I accomplish this?
0
Comment
Question by:LuckyLucks
  • 6
  • 5
  • 3
14 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24817501

Hi,
you could  'mutt', which has the builtin capability of sending attachments (using MIME) -

echo "This is a body text" | mutt -a file1.html -s "Files for the month" tom.dick@harry.com
mutt can send CC (-c option) and BCC (-b option), too.
wmp
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24817530
... with two files (sorry, saw that requirement too late)
echo "This is a body text" | mutt -a file1.html -a file2.xls -s "Files for the month" tom.dick@harry.com
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24817561
if you have zip command then try

zip myattachment.zip *.xls *.html
uuencode myattachment.zip myattachment.zip | mail -s "Files for the month" tom.dick@harry.com
0
 

Author Comment

by:LuckyLucks
ID: 24818047
woolmilkproc:

I am getting mutt not found. I guess we do not have this mail client. Can we accomlish the same with mail?
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24818059
what os do you run?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24818072
What is your OS? You can get mutt for almost any platform!
0
 

Author Comment

by:LuckyLucks
ID: 24818236
unix aix
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24818283
OK,
find mutt on the AIX toolbox CD which came with your system, or here
http://www-03.ibm.com/systems/power/software/
Just click 'Alphabetical ...', download mutt and install with 'rpm -i ...'
wmp
 
 
 
0
 

Author Comment

by:LuckyLucks
ID: 24818333
I can not download softwares onto the AIX boxes. This is administered by admins and they will likely not install anything on my profile or company wide. Any other idea?


BTW omar I dont have zip either.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24818399
OK,

so you will have to rely on uuencode and e.g. 'tar'

tar -cvf monthfiles.tar file1.xls file2.html
uuencode monthfiles.tar monthfiles.tar | mail -s "Files for the month" tom.dick@harry.com

Note however, that 'tar' must exist at the target system!


0
 

Author Comment

by:LuckyLucks
ID: 24823895
Can I add a body test by expanding it as :

tar -cvf monthfiles.tar file1.xls file2.html
uuencode monthfiles.tar monthfiles.tar | mail -s "Files for the month" -b "Please open the attachment with winzip.\n Contents include three files: 1) file1 2) file2"  tom.dick@harry.com
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24823966
There is no -b flag with 'mail'
What is it supposed to do? Make up a body? That's unfortunately not possible.
What you could try (I never used it and have no time to test now -

tar -cvf monthfiles.tar file1.xls file2.html
uuencode monthfiles.tar monthfiles.tar  > attach.txt
echo "Please open the attachment with winzip.\n Contents include three files: 1) file1 2) file2" > body.txt
cat body.txt attach.txt | mail -s "Files for the month" tom.dick@harry.com
wmp
0
 

Author Comment

by:LuckyLucks
ID: 24824513
Tis doesnt attach the attachment i.e attach.txt , simply sends out an email with the bosy
0
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 total points
ID: 24825037
I think it is not possible to send body along with attachments ! I think many zipping s/w can untar tar files
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now