Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Need to attach files to email in ksh

Posted on 2009-07-09
14
525 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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
 
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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
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…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 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