Date: Mon, 13 Sep 2004 11:31:55 -0600 (MDT) From: "Ryan Sommers" <ryans@gamersimpact.com> To: freebsd-questions@freebsd.org Subject: Mail from a shell script? Message-ID: <50164.208.4.77.15.1095096715.squirrel@www2.neuroflux.com>
next in thread | raw e-mail | index | archive | help
I'm attempting to have a few shell scripts email output. I'm running into a few problems and was wondering if there were any ways to overcome them in a shell script or whether I'll have to go to perl or not. (Note, shell doesn't matter, I've been using sh but recently went to bash since sh on solaris (one of the machines the scripts get used on) doesn't support the -e expression for test(1)). First problem I ran into. I'm attempting to send the mail via `which mail`. I first was going to attempt to concatenate the message via "message=${message}$'\n'<other line>" However, this strips the newlines out of the variable (both sh and bash). I then tried using the <<string redirection in bash/sh and same thing happened. My next thought was to open an fd through which to pipe output since the shells support it. However, it seems they only support opening a file for read/write, not a pipe. So, my ultimate question is, is there any way to send an email from a shell script without creating a "wrapper script" that pipes the output of one script into the mail program. Ie script1 contains only "script2 | mail <recip>". Ryan ryans@gamersimpact.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50164.208.4.77.15.1095096715.squirrel>