title: 'script' command doesn't print anything when started by systemd in TTY
body: <p><strong>General goal is:</strong> use <code>rclone</code> during shutdown for sync with cloud and modify its output a bit. I've created a systemd unit:</p>
  
  <pre><code>[Unit]
  Description=Syncing with MEGA cloud storage v78
  After=network-online.target
  
  [Service]
  User=yevhenii
  Type=oneshot
  ExecStart=/bin/true
  ExecStop=/usr/local/sbin/auto-sync.sh
  RemainAfterExit=true
  TimeoutStopSec=0
  TTYPath=/dev/console
  StandardOutput=tty
  StandardError=inherit
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>It starts <code>auto-sync.sh</code> at shutdown and reboot. The script can distinguish one from another and perform sync only during shutdown. Okay, how to modify rclone's output ? The simplest approach is below and it doesn't work since <code>rclone</code> detects that its output is not a console and therefore does not print ANSI codes that perform formatting:</p>
  
  <pre><code># doesn't work well, formatting is ugly without ANSI codes
  # prints in terminal emulator, prints in TTY during shutdown
  
  rclone sync "$FROM" "$TO" --progress | while read line; 
      do
          echo "[rclone] $line"
      done
  </code></pre>
  
  <p>So, I use <code>script</code> utility that performs command's output logging and emulates(!) console for executed command (it preserves <code>rclone</code> to print ANSI codes). Exactly what I needed!</p>
  
  <pre><code># works like a charm
  # prints in terminal emulator, does NOT print in TTY during shutdown
  
  script --return --quiet --command "rclone sync $FROM $TO --progress" /dev/null | while read line;
      do
          echo "[rclone] $line" #works like a charm
      done
  </code></pre>
  
  <p><strong>The problem is</strong> that it works in ubuntu terminal emulator and doesn't in TTY that is showed during shutdown. Does anybody know how to fix this ? Thank you!</p>