Send mail from prompt
Hi,
Could anyone help me with the following: I want a script that I would put in a cronjob doing the following: Print the contents of a directory to a file and then email that file to me on a daily basis. Thanks, Stefaan |
this would mail you the contents directly:
Code:
ls /example | mail -s "Contents of /example" your@email.com Code:
ls /example > /tmp/example.txt |
Ripper, that seems to work fine, the attachment one however stumbles over the -a option, doesn't seem to exist, running FC2.
But I'm not that fuzzed in having it as an attachment. Cheers mate. |
hmmm, that's weird... do a "man mail" and confirm your mail command supports the "-a" option...
EDIT: wait, do you mean the "-a" option doesn't exist or do you mean the file you want to attach doesn't exist?? |
man mail doesn't list -a as an option nor do I see any references to attachments.
|
well, i'm on slackware, so "mail" is a link to "nail", as you can see here:
Code:
win32sux@darkstar:~$ ls -l /usr/bin/mail so when i do a "man mail" i can see the "-a" option in there: Quote:
|
I don't think "mail" handles mime type attatchments. I would do it like this:
10 17 * * Mon-Fri ls -l ~/tmp > ~/tmp_dir.txt | cat ~/tmp_dir.txt | mail -s "tmp_dir" kencaz@linuxmail.org This would create a file tmp_dir.txt in my home folder and mail me the contents but not as an attatchment everyday at 5:10pm KC |
Right, I'll have to install nail then coz I do see a need for attachments sent from the prompt coz I want to mail things like the history file etc.
You've been most helpfull! |
Quote:
|
Mail with a different "from" address
I'm looking for something similar. I can use "mail" to send mail from a command line, but there seems to be no way to specify an a different return address. Does anyone know of a utility other than "mail" that will let you change the reply-to address?
Thanks! Cory |
Quote:
I'm sure there are probably 5 other ways to do it, but that's what just came to mind at the time. KC |
okay, but i'm still not sure what the pipe in red in your commands is doing:
Code:
ls -l ~/tmp > ~/tmp_dir.txt | cat ~/tmp_dir.txt | mail -s "tmp_dir" kencaz@linuxmail.org Code:
ls -l ~/tmp > ~/tmp_dir.txt ; cat ~/tmp_dir.txt | mail -s "tmp_dir" kencaz@linuxmail.org |
Re: Mail with a different "from" address
Quote:
Quote:
|
Quote:
KC |
All times are GMT -5. The time now is 06:18 PM. |