{"id":6874,"date":"2014-05-08T00:27:17","date_gmt":"2014-05-08T00:27:17","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/08\/use-logger-in-shell-script-collection-of-common-programming-errors\/"},"modified":"2014-05-08T00:27:17","modified_gmt":"2014-05-08T00:27:17","slug":"use-logger-in-shell-script-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/08\/use-logger-in-shell-script-collection-of-common-programming-errors\/","title":{"rendered":"Use logger in shell script-Collection of common programming errors"},"content":{"rendered":"<p>The shebang is correct as both #!\/bin\/sh and #!\/bin\/bash can be used*, however, IIRC, you should use pipes not redirect for logger as it&#8217;s a program not a file.<\/p>\n<p>Try this script:<\/p>\n<pre><code>\n#!\/bin\/sh\nntpd -qnp pool.ntp.org 2&gt;&amp;1 |logger\n\n<\/code><\/pre>\n<p>*If you use #!\/bin\/sh for your scripts, they are supposed to be posix compliant, ie run well on solaris and AIX. If ever you use some bash specific features, #!\/bin\/bash have to be used because there&#8217;s no more portability.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The shebang is correct as both #!\/bin\/sh and #!\/bin\/bash can be used*, however, IIRC, you should use pipes not redirect for logger as it&#8217;s a program not a file. Try this script: #!\/bin\/sh ntpd -qnp pool.ntp.org 2&gt;&amp;1 |logger *If you use #!\/bin\/sh for your scripts, they are supposed to be posix compliant, ie run well [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6874","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6874"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6874\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}