-
Sending mail with a script
I am using Postfix on a Mandrake Linux server and I am trying to figure out what seems to be a simple task.
I need a script to send an email to me when complete.
If I put
mail root -s "Backup Complete"
in my script it asks for, first, a message to mail, then, a cc: address. Then there's the matter of having to issue a C-d to end the message
Any help would be appreciated.
Registered Linux User #324436
Registered Linux Box #209059
One by one, the Penguins are taking my sanity...
-
Actually, if I put an echo statement at the end of the script would it automatically email the output to root?
Still would like to know how to handle the rest of the stuff I mentioned above... for instance, when I want to send an email to my cellphone telling me about a possible security risk, etc...
Registered Linux User #324436
Registered Linux Box #209059
One by one, the Penguins are taking my sanity...
-
Actually i had the same problem . To make it easier you should make a normal textfile with the message you want to send and then just issue :
cat textfile | sendmail email@address
I think this will do the trick .
For sending an SMS to your mobile ..... this might help :
SMSTerm
As long as your telephone network is supported by ICQ ...
David
For iam Costanza , lord of the idiots
Registered Linux User #278996
-
that's all fine except that I'm not using sendmail.
and my cellphone has an email address (MY7DIGITPHONENUMBER@mobile.mycingular.com) which is pretty standard on any cingular phone (with SMS, that is).
Thanks anyway Dave2001
Registered Linux User #324436
Registered Linux Box #209059
One by one, the Penguins are taking my sanity...
-
mmm if you are not using sendmail - start using it hehe
I think this should work with other progs as well .... just give it a try .
David
For iam Costanza , lord of the idiots
Registered Linux User #278996
-
have your script print out a completion message, and then run the script as script | mail -s "job complete" user@computer.com
When the only tool you have is a hammer, all of your problems start to look like nails.
-Abraham Maslow
-
mail me@somewhere.com -s "some subject" < theFile.txt
-
Tried that, it wouldn't work
I just put echo "Job Complete on `date`" at the end of the script.
So far it seems to be working... I think.
Because I also put something that I knew would return a warning in there as well... and I got an email this morning.
Registered Linux User #324436
Registered Linux Box #209059
One by one, the Penguins are taking my sanity...
-
If this is something that runs regularly, and you're running it through cron, you should get all the output through your email (assuming it's set up so that cron can use it).
"I'm not closed-minded, you're just wrong" - Bucky Katt
-
help with post fix
I have installed post fix on my linux mandrake 8.2. I have 2 ? 1st I would like to know how to add users to it. And 2nd Every time I go to mail.mydomain the mail progrom can not find the server . Can anyone help ?
-
When you add users to Linux (it was userconf in 8.1) they are automatically added in postfix.
When you go to mail.mydomain.com it can't see your domain name because it's local. Try using the IP address of your server instead.
Registered Linux User #324436
Registered Linux Box #209059
One by one, the Penguins are taking my sanity...
-
post fix
Your server has unexpectedly terminated the connection. Possible causes for this include server problems, network problems, or a long period of inactivity. Account: '207.68.84.188', Server: '207.68.84.188', Protocol: POP3, Port: 110, Secure(SSL): No, Error Number: 0x800CCC0F Thank you for your info this is what I get when I try that and my domain ?
-
I use this syntax to send mails within a script:
`/usr/bin/mailx -s " <subject>" "<e-mail-adress>" << EOF
<text>
EOF`
Last edited by cwolf; 07-17-2002 at 07:37 AM.
-
`/usr/bin/mailx -s " <subject>" "<e-mail-adress>" << EOF text EOF`
I tried using this syntax and the email was sent but with no text at all.
Does anyone have any other suggestions?
And how about attaching files from the command line or a script?
Dizzy
Speak slow and loud, I'm not very good at this.
-
Here is a simple script I have that mounts one of our network drives, backs up the web site, and emails me the results
Code:
# Mount the website dir as /mnt/website
mount -t smbfs -o username=xxx,password=xxx //webserver/secure /mnt/website
# Declare and define variables
tempdir=/home/backup_temp
filename=/home/backs/site_$(date '+%m%d%y').tar
# Create temp dir to hold the site
mkdir $tempdir
# Copy ENTIRE site to tempdir
cp -Rf /mnt/website/* $tempdir/
# Remove .~asp files
rm -f $tempdir/*~asp
# tar and zip the temp dir
tar -cf $filename $tempdir
gzip $filename
# Clean the mess I made with the tempdir
rm -Rf $tempdir
# Create & send email message
echo "Website successfully backed up to "$filename".gz" > /home/backs/tmp_email
ls -lH /home/backs >> /home/backs/tmp_email
mail -s"*** Back up notification ***" xxx@bxxx.com < /home/backs/tmp_email
# Remove temp email file
rm -f /home/backs/tmp_email
# Un-Mount //website/secure
umount /mnt/website
-goon12
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|