I am doing a md5sum to verify nightly transfer of files between servers and want to email the results to support.
Everything works fine except reading the contents of the check file into mail.
Any suggestions or help would be much appreciated.
#!/bin/bash cd /bak md5sum -b `date '+%m-%d-%y'`.tgz > `date '+%m-%d-%y'`.ver diff -s `date '+%m-%d-%y'`.md5 `date '+%m-%d-%y'`.ver > `date '+%m-%d-%y'`.chk #outfile=`date '+%m-%d-%y'`.chk #setup name of file to read into mail mail -s 'file verify' me@mymailaddr.com <<MAIL_IN ~r `date '+%m-%d-%y'`.chk
. MAIL_IN
exit
entering the same mail commands from a command prompt works.
Mark
on 11/2/2007 3:39 PM Mark Snyder spake the following:
I am doing a md5sum to verify nightly transfer of files between servers and want to email the results to support.
Everything works fine except reading the contents of the check file into mail.
Any suggestions or help would be much appreciated.
#!/bin/bash cd /bak md5sum -b `date '+%m-%d-%y'`.tgz > `date '+%m-%d-%y'`.ver diff -s `date '+%m-%d-%y'`.md5 `date '+%m-%d-%y'`.ver > `date '+%m-%d-%y'`.chk #outfile=`date '+%m-%d-%y'`.chk #setup name of file to read into mail mail -s 'file verify' me@mymailaddr.com <<MAIL_IN ~r `date '+%m-%d-%y'`.chk
. MAIL_IN
exit
entering the same mail commands from a command prompt works.
Mark
Cron doesn't always have access to the same path and environment as a logged in user. You might have to export some environment var's in the beginning of the script.
Scott Silva wrote:
on 11/2/2007 3:39 PM Mark Snyder spake the following:
I am doing a md5sum to verify nightly transfer of files between servers and want to email the results to support.
Everything works fine except reading the contents of the check file into mail.
Any suggestions or help would be much appreciated.
#!/bin/bash cd /bak md5sum -b `date '+%m-%d-%y'`.tgz > `date '+%m-%d-%y'`.ver diff -s `date '+%m-%d-%y'`.md5 `date '+%m-%d-%y'`.ver > `date '+%m-%d-%y'`.chk #outfile=`date '+%m-%d-%y'`.chk #setup name of file to read into mail mail -s 'file verify' me@mymailaddr.com <<MAIL_IN ~r `date '+%m-%d-%y'`.chk
. MAIL_IN
exit
entering the same mail commands from a command prompt works.
Mark
Cron doesn't always have access to the same path and environment as a logged in user. You might have to export some environment var's in the beginning of the script.
thanks Scott
While this is true script is not reading the contents of the diff into mail when the script is executed from my normal shell. Is there another way to do this?
On Fri, Nov 02, 2007 at 04:39:32PM -0600, Mark Snyder alleged:
I am doing a md5sum to verify nightly transfer of files between servers and want to email the results to support.
Everything works fine except reading the contents of the check file into mail.
Any suggestions or help would be much appreciated.
#!/bin/bash cd /bak md5sum -b `date '+%m-%d-%y'`.tgz > `date '+%m-%d-%y'`.ver diff -s `date '+%m-%d-%y'`.md5 `date '+%m-%d-%y'`.ver > `date '+%m-%d-%y'`.chk #outfile=`date '+%m-%d-%y'`.chk #setup name of file to read into mail mail -s 'file verify' me@mymailaddr.com <<MAIL_IN ~r `date '+%m-%d-%y'`.chk
. MAIL_IN
exit
entering the same mail commands from a command prompt works.
First, stop running `date` over and over. Run it once at the top and set a variable.
Second, what is actually going wrong? Is there an error message?
Is this a cronjob? If so, then don't bother using 'mail'; just echo to stdout and let cron handle the mailing.
Garrick Staples wrote:
On Fri, Nov 02, 2007 at 04:39:32PM -0600, Mark Snyder alleged:
I am doing a md5sum to verify nightly transfer of files between servers and want to email the results to support.
Everything works fine except reading the contents of the check file into mail.
Any suggestions or help would be much appreciated.
#!/bin/bash cd /bak md5sum -b `date '+%m-%d-%y'`.tgz > `date '+%m-%d-%y'`.ver diff -s `date '+%m-%d-%y'`.md5 `date '+%m-%d-%y'`.ver > `date '+%m-%d-%y'`.chk #outfile=`date '+%m-%d-%y'`.chk #setup name of file to read into mail mail -s 'file verify' me@mymailaddr.com <<MAIL_IN ~r `date '+%m-%d-%y'`.chk
. MAIL_IN
exit
entering the same mail commands from a command prompt works.
First, stop running `date` over and over. Run it once at the top and set a variable.
Second, what is actually going wrong? Is there an error message?
Is this a cronjob? If so, then don't bother using 'mail'; just echo to stdout and let cron handle the mailing.
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Yes you are right about setting a variable, but this was supposed to be a quick and dirty.
I will want it to be a cronjob when its working, how can I get it to mail the output of the diff? and not just the stdout of the cronjob? The whole point of this is the get the output of the diff to someone.
Mark Snyder wrote:
Garrick Staples wrote:
On Fri, Nov 02, 2007 at 04:39:32PM -0600, Mark Snyder alleged:
I am doing a md5sum to verify nightly transfer of files between servers and want to email the results to support.
Everything works fine except reading the contents of the check file into mail.
Any suggestions or help would be much appreciated.
#!/bin/bash cd /bak md5sum -b `date '+%m-%d-%y'`.tgz > `date '+%m-%d-%y'`.ver diff -s `date '+%m-%d-%y'`.md5 `date '+%m-%d-%y'`.ver > `date '+%m-%d-%y'`.chk #outfile=`date '+%m-%d-%y'`.chk #setup name of file to read into mail mail -s 'file verify' me@mymailaddr.com <<MAIL_IN ~r `date '+%m-%d-%y'`.chk
. MAIL_IN
exit
entering the same mail commands from a command prompt works.
First, stop running `date` over and over. Run it once at the top and set a variable.
Second, what is actually going wrong? Is there an error message?
Is this a cronjob? If so, then don't bother using 'mail'; just echo to stdout and let cron handle the mailing.
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Yes you are right about setting a variable, but this was supposed to be a quick and dirty.
I will want it to be a cronjob when its working, how can I get it to mail the output of the diff? and not just the stdout of the cronjob? The whole point of this is the get the output of the diff to someone. _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Works fine. Please ignore my stupidity. Must still be hung over from the weekend. Still I would like to know if anyone has a way to make the mail tilde/escape options work from within a script.
On Mon, Nov 05, 2007 at 09:42:57AM -0600, Mark Snyder alleged:
Garrick Staples wrote:
On Fri, Nov 02, 2007 at 04:39:32PM -0600, Mark Snyder alleged:
I am doing a md5sum to verify nightly transfer of files between servers and want to email the results to support.
Everything works fine except reading the contents of the check file into mail.
Any suggestions or help would be much appreciated.
#!/bin/bash cd /bak md5sum -b `date '+%m-%d-%y'`.tgz > `date '+%m-%d-%y'`.ver diff -s `date '+%m-%d-%y'`.md5 `date '+%m-%d-%y'`.ver > `date '+%m-%d-%y'`.chk #outfile=`date '+%m-%d-%y'`.chk #setup name of file to read into mail mail -s 'file verify' me@mymailaddr.com <<MAIL_IN ~r `date '+%m-%d-%y'`.chk
. MAIL_IN
exit
entering the same mail commands from a command prompt works.
First, stop running `date` over and over. Run it once at the top and set a variable.
Second, what is actually going wrong? Is there an error message?
Is this a cronjob? If so, then don't bother using 'mail'; just echo to stdout and let cron handle the mailing.
Yes you are right about setting a variable, but this was supposed to be a quick and dirty.
I will want it to be a cronjob when its working, how can I get it to mail the output of the diff? and not just the stdout of the cronjob? The whole point of this is the get the output of the diff to someone.
Just cat the diff to stdout. Whatever is printed to stdout will be in the email.
Mark Snyder wrote:
I am doing a md5sum to verify nightly transfer of files between servers and want to email the results to support.
1st suggestion: use rsync to transfer the files and you don't have to double-check the results, just the exit status of the command or its stderr output. It will know whether the tranfer worked or not.
Is this a cronjob? If so, then don't bother using 'mail'; just echo to stdout and let cron handle the mailing.
Yes you are right about setting a variable, but this was supposed to be a quick and dirty.
Quick and dirty things don't write files and have to worry about filenames. See if you can do it all through pipes if you do this at all.
I will want it to be a cronjob when its working, how can I get it to mail the output of the diff? and not just the stdout of the cronjob? The whole point of this is the get the output of the diff to someone.
It's your script, make it say what you want (and nothing else) on stdout.