Solved

How to send binary file from commandline ?

Posted on 1997-08-26
11
321 Views
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.
0
Comment
Question by:wvpaepeg
11 Comments
 

Author Comment

by:wvpaepeg
ID: 2006728
Edited text of question
0
 
LVL 51

Expert Comment

by:ahoffmann
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.
0
 

Author Comment

by:wvpaepeg
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 ?
0
 
LVL 51

Expert Comment

by:ahoffmann
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
0
 

Author Comment

by:wvpaepeg
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.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 51

Expert Comment

by:ahoffmann
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.
0
 

Author Comment

by:wvpaepeg
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 )
0
 
LVL 51

Expert Comment

by:ahoffmann
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.
0
 
LVL 2

Accepted Solution

by:
df020797 earned 100 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.

0
 

Author Comment

by:wvpaepeg
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");
close(MAIL);
0;
}

0
 

Expert Comment

by:bowmanc
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' ?
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

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

17 Experts available now in Live!

Get 1:1 Help Now