Changes between Initial Version and Version 1 of waue/2010/0722


Ignore:
Timestamp:
Jul 22, 2010, 4:47:44 PM (14 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2010/0722

    v1 v1  
     1= 2010-07-22 =
     2
     3 * [備忘] 重新改用 root 身份執行的 shell script
     4{{{
     5#!sh
     6[ "`id -u`" != "0" ] && exec sudo su -c "$0" "$@"
     7}}}
     8 * [備忘] 讓標準輸出(STDOUT)與標準錯誤(STDERR)導入到 log 檔的 bash script 寫法
     9{{{
     10#!sh
     11#! /bin/bash
     12
     13TARGET="target-file"
     14
     15# file descriptor 4 prints to STDOUT and to TARGET
     16exec 4> >(while read a; do echo $a; echo $a >>$TARGET; done)
     17
     18# now STDOUT is redirected
     19exec >&4
     20exec 2>&4
     21date
     22echo "Date sent to fd4."
     23abc
     24
     25}}}