Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Oct 2017 09:54:13 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Paul Schmehl <pschmehl_lists@tx.rr.com>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>, mutt-users@mutt.org
Subject:   Re: Scripting problem
Message-ID:  <20171008095413.b0700f43.freebsd@edvax.de>
In-Reply-To: <7AB396F429EEB6890100F082@Pauls-MacBook-Pro.local>
References:  <7AB396F429EEB6890100F082@Pauls-MacBook-Pro.local>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 08 Oct 2017 00:59:39 -0500, Paul Schmehl wrote:
> I'm writing a bash script to create a db backup and email it to me once a 
> day. I'm munged some parts to not reveal details
> 
> I'm having a problem with this line:
> 
> /usr/local/bin/mutt -s $SUBJECT -i $MESSAGE -a $FILENAME -- 
> pschmehl@tx.rr.com < /dev/null
> 
> Right before this line are these lines:
> MESSAGE="path/to/message.txt"
> ADDRESS="pschmehl@mydomain"
> SUBJECT="Today's db backup"
> 
> From the commandline this runs fine, but the script returns an error:
> 
> Error sending message, child exited 67 (User unknown.).
> Could not send the message.
> 
> The mail is sent, and when it's received, the subject line is Today's. When 
> I look in the maillog, mutt tried to send email to db@hostname and 
> backup@hostname.
> 
> I changed the subject to Backup, and the error goes away.

This proves you have a quoting problem. Enclose the parameters
in the mutt call in "...", like this:

	/usr/local/bin/mutt -s "$SUBJECT" -i "$MESSAGE" -a "$FILENAME" -- pschmehl@tx.rr.com < /dev/null

When the variables are being evaluated by the shell, the quotes
during assignment are removed, and you you get is

	/usr/local/bin/mutt -s Today's db backup -i path/to/message.txt -a /whatever/filename/there.is -- pschmehl@tx.rr.com < /dev/null

The unterminated ' is handled more or less gracefully, but it
probably interferes with mutt's address detection. You can
now easily recognize the problem.



> I'm running FreeBSD 10.3-RELEASE and the script is written in bash.

Do you have any reasons not to stick to default sh? Do you use
any features specific to bash?



> Why would mutt do this?

Well, actually mutt doesn't do it - it's the shell that just does
what you told it to. ;-)




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20171008095413.b0700f43.freebsd>