Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
Source Link
robert
  • 213
  • 2
  • 4

CD with redirect to logger does not work

On Linux, the following cd works fine so cds into tmp:

/ # cd /tmp tmp # 

But this does not work (stays at root, nothing appears in /var/log/messages). Why not?

/ # cd /tmp 2>&1 | /usr/bin/logger -t Test / # 

I tried with stripping off this stderr redirect but that also did not work.

My goal is to redirect all output of my script to syslog, so also if I try to CD in a directory which does not exist/permission denied/etc. Why is it not working and how to get this working?

A normal echo does print to syslog so that does work:

echo Test | /usr/bin/logger -t Test