LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-21-2003, 09:50 AM   #1
Minuteman
LQ Newbie
 
Registered: Mar 2003
Location: Switzerland
Distribution: Redhat, Slackware
Posts: 20

Rep: Reputation: 0
Sending an automatic mail using bash + mail


Hello, I want to make a shell (bash) script that automatically sends me a message without an user interaction.

I tried: mail root -s "Hello you"

but then the program absolutely wants that I hit 2 times on the enter key... is there a way to tell bash to make a "return to the line" or a better way to do this?
 
Old 08-21-2003, 10:05 AM   #2
m0rl0ck
Member
 
Registered: Nov 2002
Distribution: A totally 133t distro :)
Posts: 358

Rep: Reputation: 31
echo hello|mail -s test "Hi dere"

and hello will appear in the message body, you can also do this with cat to read a file or just about any prog that outputs text that youd like mailed


EDIT: should have been echo hello|mail -s "Hi dere" user@host

I can cut and paste much faster than I can think

Last edited by m0rl0ck; 08-22-2003 at 03:33 AM.
 
Old 08-21-2003, 10:14 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
AFAIK it's "cat <sometext>|mail -s "<subject>" <mail@address>"
Btw, you can also send MIME attachments using "mpack" instead of "mail".
 
Old 08-21-2003, 10:15 AM   #4
Minuteman
LQ Newbie
 
Registered: Mar 2003
Location: Switzerland
Distribution: Redhat, Slackware
Posts: 20

Original Poster
Rep: Reputation: 0
It works great so, thank you all for your quick answers :-)
 
Old 08-21-2003, 01:49 PM   #5
lfur
Member
 
Registered: Jul 2003
Location: Slovenia
Distribution: Slackware & FreeBSD
Posts: 209

Rep: Reputation: 30
A bit late but ...
mail some@address.here < textfile
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix mail transfer agent not sending mail locally or to other servers sketelsen Linux - Software 3 02-09-2006 12:16 PM
Cron mail sending using outside SMTP mail server Utah Linux - Software 6 08-24-2005 08:44 PM
Sending mail through mail server. TheRealDeal Linux - Networking 17 09-12-2004 12:31 AM
Sending mail through mail server. TheRealDeal Linux - Networking 0 09-07-2004 12:43 AM
Mail Server not sending mail baye Linux - Software 1 05-28-2004 09:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration