Solved

Need to attach files to email in ksh

Posted on 2009-07-09
14
529 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
[X]
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
  • 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
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…

689 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