On Thu, 30 Sep 1999, you wrote:
>Hi All,
>
>I am trying to write a script that will run occasionally, and send email to me
>when certain events happen.  I have hit a brick wall in trying to completely
>automate
>either sendmail or mailto.  I can get them to run automagically up to where they
>expect a text message followed by ctrl-d.  I have tried unsucessfully to get it
>to send the contents of a text file as its message.  The man pages for both are
>cryptic as best.  The one for mailto seems out of whack to boot..
>
>I found a win app called wsendmail that lets you do this all on one command
>line:
>
>wsendmail <subject> <sender> <recipient> <message - "Typed in quotes" or
>contents of a file>
>
>I even have the source code for wsendmail.  I fooled around and compiled it in
>Linux just to see what would happen, but it apparently nees a couple of files,
>and I don't know enough c to get around that!!!
>
>
>Obviously, I would like to do the same in Linux.
>
>Is there something else non-GUI that I could use to completely automate the
>sending of email?  Am I missing something obvious in the man pages?


Well if the script is written so that the results of whatever is
being done by the script go to a file then the answer is easy.

#!/bin/bash

touch /tmp/text.file

#your script here.
# and output all commands as >>/tmp.text.file
# Example

ifconfig eth0 >>/tmp/file.txt

# then a small check to see if there is any text in the file.

check=`cat /tmp/text.file | wc -c`

if [ "$check" -gt 0 ]; then
  cat /tmp/text.file | mail  BryanMoorhead@AlliedHoldings
fi

# of course if there is always going to be text in the file
# then the above if statement is not needed.
# just use at the bottom of the script the cat line.

# Clean up,
rm -f /tmp/file.txt
exit 0

Note the hypens they are left slanting (cant remember the dam proper
name for them) the one on the tilde key.
I would do it in another way, but this is the simplest way i could
think of off the top of my head.

 I hope this is what you meant.
>
>Thanks,
>Bryan
--
Regards Richard
[EMAIL PROTECTED]
http://people.zeelandnet.nl/pa3gcu/

Reply via email to