From owner-freebsd-questions@freebsd.org Sun Oct 8 07:55:06 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B9070E2C116 for ; Sun, 8 Oct 2017 07:55:06 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mailrelay11.qsc.de (mailrelay11.qsc.de [212.99.187.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.antispameurope.com", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 98D8C84066 for ; Sun, 8 Oct 2017 07:55:04 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de ([213.148.129.14]) by mailrelay11.qsc.de; Sun, 08 Oct 2017 09:54:14 +0200 Received: from r56.edvax.de (port-92-195-127-141.dynamic.qsc.de [92.195.127.141]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 0BA113CBF9; Sun, 8 Oct 2017 09:54:13 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id v987sDTL002354; Sun, 8 Oct 2017 09:54:13 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Sun, 8 Oct 2017 09:54:13 +0200 From: Polytropon To: Paul Schmehl Cc: FreeBSD Questions , 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> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-cloud-security-sender: freebsd@edvax.de X-cloud-security-recipient: freebsd-questions@freebsd.org X-cloud-security-Virusscan: CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mailrelay11.qsc.de with 705446A35B9 X-cloud-security-connect: mx01.qsc.de[213.148.129.14], TLS=1, IP=213.148.129.14 X-cloud-security: scantime:.1557 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Oct 2017 07:55:06 -0000 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, ...