Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sending a Message in a single command

3 views
Skip to first unread message

Wandering Weezard

unread,
Jun 13, 2005, 2:44:40 PM6/13/05
to
I'd like to send a message from within a bash script. I have not been
successful in my attempts yet, but maybe I can show you what I've done
so far:

I set the following variables:

MESSAGE="Backup script completed on $(date +%Y%m%d)"
SUBJ="Backup Script Report"
EMAIL="wanderi...@hotmail.com"
MUTT="| ./usr/bin/mutt"

Then, I do the following:

echo "$MESSAGE $MUTT -s $SUBJ $EMAIL"

But, I have not gotten an email yet. Maybe I am doing something wrong?

Grant Edwards

unread,
Jun 13, 2005, 2:51:11 PM6/13/05
to
On 2005-06-13, Wandering Weezard <wanderi...@gmail.com> wrote:

> MESSAGE="Backup script completed on $(date +%Y%m%d)"
> SUBJ="Backup Script Report"
> EMAIL="wanderi...@hotmail.com"
> MUTT="| ./usr/bin/mutt"
>
> Then, I do the following:
>
> echo "$MESSAGE $MUTT -s $SUBJ $EMAIL"

All that command does is print the string you gave it to
stdout. You want to actually run mutt. And it's a bad idea to
hide control constructs like "|" inside variables. The "." at
the front of the path for mutt looks suspicious as well.

You proably want to do something like this:

[...]
MUTT=/usr/bin/mutt

echo "$MESSAGE" | $MUTT -s "$SUBJ" "$EMAIL"

--
Grant Edwards grante Yow! I'm a nuclear
at submarine under the
visi.com polar ice cap and I need
a Kleenex!

Wandering Weezard

unread,
Jun 13, 2005, 3:11:05 PM6/13/05
to
Okay, I changed it to your recommendations, but don't seem to be
getting any emails. Is there maybe a configuration file that I need to
check? Maybe Mutt does not know the correct domain?

Grant Edwards

unread,
Jun 13, 2005, 3:20:49 PM6/13/05
to
On 2005-06-13, Wandering Weezard <wanderi...@gmail.com> wrote:


> Okay, I changed it to your recommendations, but don't seem to
> be getting any emails.

Are you addressing me? In order to provide some context for
your question, you should quote an appropriate amount of the
posting to which you're replying. Otherwise you look like that
crazy homeless guy standing alone in the park talking to
nobody. :)

> Is there maybe a configuration file that I need to check?

Maybe. Does sending mail with mutt interactively work?

Does your MTA's log file show the mail was sent?

> Maybe Mutt does not know the correct domain?

Could be.

--
Grant Edwards grante Yow! Hey, waiter! I want
at a NEW SHIRT and a PONY TAIL
visi.com with lemon sauce!

Alan Connor

unread,
Jun 13, 2005, 5:01:46 PM6/13/05
to

Grant showed you the proper syntax, and it should work if you can send mail interactively.

AC

Stephen Patterson

unread,
Jun 13, 2005, 6:20:04 PM6/13/05
to
On 13 Jun 2005 11:44:40 -0700, Wandering Weezard wrote:
> I'd like to send a message from within a bash script. I have not been
> successful in my attempts yet, but maybe I can show you what I've done
> so far:
>
> I set the following variables:
>
> MESSAGE="Backup script completed on $(date +%Y%m%d)"
> SUBJ="Backup Script Report"
> EMAIL="wanderi...@hotmail.com"
> MUTT="| ./usr/bin/mutt"
>
> Then, I do the following:
>
> echo "$MESSAGE $MUTT -s $SUBJ $EMAIL"

Why are you doing it like this? I'd assume you're running some kind of
unix/linux system (as you've got bash) so you've probably got cron
installed. Now a backup script is something that makes sense to have
run automatically every so often (hence cron) and cron will email its
user (or the address set by MAILTO in the user's crontab) with any
text output generated by the command being run.

just my 2 cents in a "sometimes mutt isn't the answer" sense.

--
Stephen Patterson st...@patter.mine.nu http://patter.mine.nu/
Linux Counter No: 142831 GPG Public key: E3E8E974
"Whoever said nothing is impossible never tried slamming a revolving door."
-- Melissa O'Brien

Alan Connor

unread,
Jun 13, 2005, 6:52:36 PM6/13/05
to
On comp.mail.mutt, in
<slrndas1om.2h...@patter.mine.nu>, "Stephen Patterson"
wrote:


> On 13 Jun 2005 11:44:40 -0700, Wandering Weezard wrote:
>
>> I'd like to send a message from within a bash script. I have
>> not been successful in my attempts yet, but maybe I can show
>> you what I've done so far:
>>
>> I set the following variables:
>>
>> MESSAGE="Backup script completed on $(date +%Y%m%d) "
>> SUBJ="Backup Script Report EMAIL="wanderi...@hotmail.com"
>> MUTT="| ./usr/bin/mutt "
>>
>> Then, I do the following:
>>
>> echo "$MESSAGE $MUTT -s $SUBJ $EMAIL"
>
> Why are you doing it like this? I'd assume you're running
> some kind of unix/linux system (as you've got bash) so you've
> probably got cron installed. Now a backup script is something
> that makes sense to have run automatically every so often
> (hence cron) and cron will email its user (or the address set
> by MAILTO in the user's crontab) with any text output generated
> by the command being run.
>
> just my 2 cents in a "sometimes mutt isn't the answer" sense.
>

You have a point, if it is a conventional backup script.

But cron could just as well call mutt as mail(x).
Just take a symlink :-)


AC

0 new messages