LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-10-2010, 01:53 AM   #1
abakhiet
Member
 
Registered: Apr 2010
Location: Assiut, Egypt
Posts: 166

Rep: Reputation: 15
Exclamation Mail Script


Hola,
i need to ask about how can i make some script by bash that can make update to my server and then send a confirmation mail to my mail box in gmail ???
i have some recommendation about that
=================
!/bin/bash
yum -y update | mail -s "Update Server" mybox@gmail.com
=================
this script was activated, but it seems that it has some problems, it gives me this error "/usr/sbin/sendmail: Exec format error"
i need to say that i can send/receive mails by thunderbird and squiirrelmail and all is fine, but i don't know what happens to my termainal mail agents
my server is:
Linux Centos 5.5
Postfix mail server
Thanks in advance ...
 
Old 07-10-2010, 02:49 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
firstly
!/bin/bash
should be
#!/bin/bash

secondly, try using the full path to the mail command (/bin/mail ?)
To find out what it is use
Code:
which mail
Thirdly, this script must be [owned by / run as] root if you are to run yum update.

As root, create the script and chmod +x <scriptname>
Then copy the script to /etc/cron.daily/<scriptname>

Also, the parameters to yum may be causing problems when piped through mail.
Easy fix is to create a script called my_update containing ONLY
Code:
#!/bin/bash
yum -y update
and chmod +x my_update
Then your original script in cron.daily would become
Code:
#!/bin/bash
cd /path/to/my_update/script
./my_update | /bin/mail -s "Update Server" mybox@gmail.com

Last edited by smoker; 07-10-2010 at 03:03 AM.
 
Old 07-10-2010, 09:48 AM   #3
abakhiet
Member
 
Registered: Apr 2010
Location: Assiut, Egypt
Posts: 166

Original Poster
Rep: Reputation: 15
thanks a lot,
I need to say that you are right in the first qoute, but in the others i need to say that it was works fine, but something happeans and it stops and gives me that error.
please help !!!
 
Old 07-10-2010, 10:43 AM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
I don't understand what you are saying. "It was works fine" ?

What did you do when you installed Postfix ? It appears that sendmail is broken.
 
Old 07-10-2010, 12:53 PM   #5
abakhiet
Member
 
Registered: Apr 2010
Location: Assiut, Egypt
Posts: 166

Original Poster
Rep: Reputation: 15
Thanks for your reply,
i mean that my mail server works fine, i can send/receive mails using my mail client "ThunderBird", but i can't do that using my termainal mail clients like Mail or Mutt
i wish that i clearify my idea
 
Old 07-11-2010, 09:58 AM   #6
abakhiet
Member
 
Registered: Apr 2010
Location: Assiut, Egypt
Posts: 166

Original Poster
Rep: Reputation: 15
Really i think i find the analogy of the problem, but i need to know how to make it.
I think that the termainal commands for mail service still uses sendmail, but today i'm using postfix.
so, i need to know how to make it uses postfix
 
Old 07-11-2010, 12:50 PM   #7
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Postfix has it's own program called sendmail for compatibility with programs that need sendmail access. Either it wasn't installed properly or it has been broken somehow. I would check your postfix install.
 
Old 07-11-2010, 02:32 PM   #8
abakhiet
Member
 
Registered: Apr 2010
Location: Assiut, Egypt
Posts: 166

Original Poster
Rep: Reputation: 15
Red face

Quote:
Originally Posted by smoker View Post
Postfix has it's own program called sendmail for compatibility with programs that need sendmail access. Either it wasn't installed properly or it has been broken somehow. I would check your postfix install.
cool, please tell me what files you want to see, by the time, i need to say that i make some relay over my provider mail server to send mail through his mail server...
 
Old 07-11-2010, 02:57 PM   #9
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
I don't use postfix, so I don't want to see any files. I suggest you reinstall postfix. You can check the postfix config files for specific settings, but I would agree with this persons comment.
Quote:
'Exec format error' isn't specifically a sendmail error. That's the
OS telling you that you've tried to run a file which isn't a binary
executable.
Also read the thread "Post fix error" found here.
 
  


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
Using 'mail' in a script to send mail on an alternate port? tim914 Linux - Software 4 01-16-2009 03:23 PM
help: using cron + my bash script --> don't want mail from script beeblequix Linux - General 7 11-23-2007 09:25 PM
Shel script mail send ("/" in mail address) problem anaid Linux - Networking 3 08-23-2005 07:41 AM
CGI Script runs to send mail, but mail is never sent robertwo Linux - Newbie 2 06-10-2004 09:57 AM
E-Mail notification to users via SMS (gateway script ok, but notification script?!?) Riku2015 Linux - Networking 10 03-08-2002 10:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:06 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