On 12 November 2013 00:56, Kris Springer <kspringer at innovateteam.com> wrote:
When I run that command as user xymon, it attempts then hangs. root at ip:~# su xymon
Good.
xymon at ip:/home/ubuntu$ su xymon -c xymoncmd echo "mail test" | $MAIL "Xyon [12345] VM-Firesall:proc CRITICAL (RED)" support at innovateteam.com
No, this won't do the same thing as I said. The "$MAIL" variable will be expanded by the shell of the xymon user, which won't have run xymoncmd yet, and so $MAIL probably will be defined as /var/mail/xymon - the path to the xymon user's mailbox file, /var/mail/xymon (which doesn't exist because the xymon user has never received mail).
(Also, you have already run "su xymon" so no need to do it a second time.)
Instead, you should run xymoncmd, and then at a command prompt (once $MAIL is defined) run the subsequent command. You could even do "echo $MAIL" in the middle, to be sure, like so:
$ su xymon $ echo $MAIL /var/mail/xymon $ xymoncmd $ echo $MAIL /usr/bin/mail $ echo "mail test" | $MAIL "what ever you want here" support at innovateteam.com
Cheers Jeremy