Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


How to send binary file from commandline ?

Posted on 1997-08-26
Medium Priority
Last Modified: 2010-04-21
How can you send a binary file via e-mail, without using 'uuencode', and invoking the mailing process from the UNIX-command line ? I thought of mailing an ASCII-mail and then as a sort of attachment, the binary file. However 'mail' and 'sendmail' don't support MIME-file-attachment.
Some people suggested to use 'Elm', but I search for a straight way, so that there are no problems to use the command in a CGI-script or a UNIX-shell script.

You can wonder why I need this. Well, people can visit my services, and let carry out large calculations about construction models. Because the calculations usually take too much time to wait online for the results, I offer the possibility to enter their e-mail address and send the results by mail. The results are presented in a graphical format, showing the most dangerous stresses and strains in the construction model.
I'd like to send this binary file, so that people find it as an attachment (e.g. in Pine) in their mailbox.
Any help would be very welcome.
Question by:wvpaepeg
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

Author Comment

ID: 2006728
Edited text of question
LVL 51

Expert Comment

ID: 2006729
You **must** convert it anyhow to ASCII, either bei uuencode, base64, mime or whatever.
Your MUA (mail user agent) elm, mail, xmail doesn't matter; the MTA (mail transport agent) sendmail needs to get the data in ASCII, some MUAs just do this work on the fly for attachements.

Author Comment

ID: 2006730
But can't you use 'Elm' and other MUA's from the command line and attach a binary file to it ? How do these MUA's implement these facilities ?
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 51

Expert Comment

ID: 2006731
Don't know :-(may be elm does it in one of its configuration files).
But what restricts you to use a command like:
   uuencode binary_file binary_file | mail -s "subject" addr

Author Comment

ID: 2006732
Well, I don't like this way, because my calculations should be used in a later stadium for business companies and others.
And the graphics file is usually 200 KB big, so I have to send four pieces of circa 64 KB, which they have to add together. This is not a user-friendly way of working.
I thought they would be able to find the file in attachment and just save it as a whole.
I read something about Elm, using with a parameter [include <file_name>], but I don't know if you can use it from the commandline.
LVL 51

Expert Comment

ID: 2006733
What's about your 64KB pieces? Do you split your data because of delivering problems (if > 50KB)? Then "elm include ..." (if available) will not help, because it wont split it for you.

Author Comment

ID: 2006734
Well, since 64 KB is a standard size for e-mail to handle, uuencode splits up the files into pieces of 64 KB.
But regarding to an Elm FAQ, the [include file_name] should handle about binary files, and send them in attachment without any splitting ( what of course it doesn't noeed to, because you don't have to add the binary pieces, it' only in case of using uuencode )
LVL 51

Expert Comment

ID: 2006735
> Well, since 64 KB is a standard size for e-mail to handle, uuencode splits up the files into pieces of 64 KB.

Who states this?
I.g. there is no limit for any email, theoretically. Just some ancient servers, forwarding email, may have such restrictions. This was the reason that mails should not exceed 64KB.
I don't know of any encoding (uuencode, base64, etc.) which are doing any splits; it must always be done before.

Accepted Solution

df020797 earned 200 total points
ID: 2006736
Use the command rcp (user@host:)PATH (user@host:)PATH if the
r-services am open on the system. To achieve higher security (encryoted passowrd, RSA auth and encryoted tarffic during the copy) isntall ssh on both machines and use scp with same syntax.


Author Comment

ID: 2006738
I realize this is contrary to the original request -- no uuencode -- but here is the way I did
it using perl and it works great: (ahoffmann says the same thing)

sub SendMail {
open(MAIL,"|uuencode orig_filename attached_filename|mail $email");


Expert Comment

ID: 2006737
The visitors are not necessarily on the same network as I do. At this time they are, because we are in a developing phase, but in a later stadium the goal is to send these files to people on remote networks and I fear 'rcp' won't work then. I use this command already to copy files within our network, but it is rather slow.

By the way, can you explain some more about the terms 'RSA' and 'scp' ?

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap ( Version 1.2 2.      Jpcap( Version 0.6 Prerequisite: 1.      GCC …
FreeBSD on EC2 FreeBSD ( is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

670 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