Sending Files by E-mail
Often, we have files we wish to send colleagues and friends by e-mail. Depending on the type of file you wish to send, there is a Linux command to make the process easy for you.
The shell archive file command shar is very useful for combining plaintext files into one file, which can then be sent by e-mail. shar writes shell commands for unpacking the output file inside the file itself, as well as code to verify the content using an MD5 checksum. It is much easier to use than the archive command tar, whose complexities can trip up even an expert. All you have to do to run shar is type:
shar input_filenames > filename.shar
It will take all the input files and write them to the output file, embedding the unpacking commands as it goes. The extension conventionally used with shar output files is .shar. To unpack the file, you don't need to know the embedded commands or retrieve them from the file yourself. Instead, use the command sh. The first argument to uuencode is the input file name; the second is the name to put in the output file header. We will use the same name for both. Type:
sh filename.sharThe sh command will do the work for you by reading the file, extracting the commands and executing them to unpack the archive.
It is permissible to use wild cards in naming your shar input files, so you can easily pack all the files in one or more directories. Just remember, the files must all be plaintext—no binaries.
The purpose of the shar command is quite similar to that of tar. However, the command and its format are much easier to remember, and since the output is plaintext instead of binary, it does not need to be encoded to send it as e-mail.
Non-plaintext files such as binaries and graphics must be encoded before e-mailing them. First, pack and compress your files using tar, which outputs a binary file. We won't go into tar in detail here, since it has been discussed before: see “Tar and Taper for Linux” by Yusuf Nagree, Linux Journal, February 1996 (http://www.linuxjournal.com/lj-issues/issue22/1216.html). A simple command to pack and compress all the files in the current directory would look like this:
tar -cvzf tar_files.tgz *
Now, the tar file can be encoded using the command uuencode by typing:
uuencode tar_file.tgz tar_file.tgz > mail_fileThe output file can now be put into e-mail and sent off into the ether.
The recipient can save the e-mail (perhaps as mail.save) and decode the file easily—no need to even remove mail headers. Simply use the command uudecode by typing:
uudecode will do just what its name says: decode the mail file, leaving a file called tar_file.tgz in the current directory. To unpack the tar file, type:
tar -xvzf tar_file.tgzA single graphics file can be encoded and decoded in the same way, skipping the tar step since an archive file is not needed.
|Contrast Security's Contrast Enterprise||Aug 30, 2016|
|illusive networks' Deceptions Everywhere||Aug 29, 2016|
|Happy Birthday Linux||Aug 25, 2016|
|ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs||Aug 24, 2016|
|Updates from LinuxCon and ContainerCon, Toronto, August 2016||Aug 23, 2016|
|NVMe over Fabrics Support Coming to the Linux 4.8 Kernel||Aug 22, 2016|
- Contrast Security's Contrast Enterprise
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- illusive networks' Deceptions Everywhere
- Happy Birthday Linux
- What I Wish I’d Known When I Was an Embedded Linux Newbie
- New Version of GParted
- ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs
- Tech Tip: Really Simple HTTP Server with Python
- Returning Values from Bash Functions
- All about printf
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide