Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 08 Nov 2017 16:53:05 -0500
From:      Ernie Luzar <luzar722@gmail.com>
To:        Polytropon <freebsd@edvax.de>
Cc:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: sh script echo to  syslog
Message-ID:  <5A037CC1.2030200@gmail.com>
In-Reply-To: <20171108220837.c6cb234d.freebsd@edvax.de>
References:  <5A036890.7090204@gmail.com> <20171108220837.c6cb234d.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Polytropon wrote:
> On Wed, 08 Nov 2017 15:26:56 -0500, Ernie Luzar wrote:
>> Hello list;
>>
>> I have a sh script that I use echo "message text" and it shows on the 
>> terminal console that started the script. Thats ok, but I would like to 
>> also have that same message posted the syslog.
> 
> The easiest way is to use the "logger" command, for example:
> 
> 	logger -t <scriptname> "<message text>"
> 
> If you omit -t <name>, the user account under which the script
> runs will be logged; it's probably easier to use the scripts
> own identifier for this purpose. If you don't want it to be
> hard-coded, use this:
> 
> 	logger -t `basename $0` "<message text>"
> 
> Or with one external program call less:
> 
> 	logger -t ${0##*/} "<message text>"
> 
> That's probably the most convenient approach. :-)
> 


Thanks to all who replied.

Logger was just what I needed.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5A037CC1.2030200>