Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending File through email

 
Ajai
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can anybody tell me the command to send logs (files) through e mail in UNIX.Assume file is residing in UNIX dir.


Thanks
Rampreet
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a strict policy on display names, which must be a real first and last name with a space between.

Please go here and fix your display name up, pronto. Thanks, pardner!
 
Lewin Chan
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, on Linux that depends on which MTA you have installed. There are quite a few choices I think, sendmail/postfix etc etc. Commonly sendmail is installed for the local user to run from the commandline. Here's an example of using that...

(
echo "To: Me <me@me.com>"
echo "From: You <you@you.com>"
echo "Subject: Here's the file I really wanted to send you"
echo
cat the_file_you_wanted_to_send
)> /usr/lib/sendmail -t

So basically here, you are using cat to print the file you wanted to send to the screen, this is redirected to the sendmail program

The -t option on sendmail is to "read message for recipients" so it parses the To/From/ lines for that info. You don't have to use it in that fashion of course, you can specify all those things on the commandline.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic