Linux2010.07.07 16:30
글들을 찾아보면
comand > logfile 2>&1
이라고 하면 command를 실행하면서 생기는 출력(stdout)과 에러(stderr)을 logfile로 저장한다고 한다.

하지만, 막상 저장해보면 순서가 뒤죽박죽 되는것으로 보인다.
$ v4l-info /dev/video0 2> v4l.dev0 1>&2
### video4linux device info [/dev/video0] ###
general info
    VIDIOCGCAP
        name                    : "DC10plus[0]"
        type                    : 0x29 [CAPTURE,OVERLAY,CLIPPING]
        channels                : 3
        audios                  : 0
        maxwidth                : 640
        maxheight               : 480
        minwidth                : 48
        minheight ioctl VIDIOCGTUNER: Invalid argument
ioctl VIDIOCGAUDIO: Invalid argument
              : 32

channels
    VIDIOCGCHAN(0)
        channel                 : 0
        name                    : "Composite"
        tuners                  : 0
        flags                   : 0x0 []
        type                    : CAMERA
        norm                    : 1
    VIDIOCGCHAN(1)
        channel                 : 1
        name                    : "S-Video"
        tuners                  : 0
        flags                   : 0x0 []
        type                    : CAMERA
        norm                    : 1
    VIDIOCGCHAN(2)
        channel                 : 2
        name                    : "Internal/comp"
        tuners                  : 0
        flags                   : 0x0 []
        type                    : CAMERA
        norm                    : 1

tuner

audio

picture
    VIDIOCGPICT
        brightness              : 32896
        hue                     : 32896
        colour                  : 33026
        contrast                : 33026
        whiteness               : 0
        depth                   : 16
        palette                 : YUYV

buffer
    VIDIOCGFBUF
        base                    : (nil)
        height                  : 768
        width                   : 1024
        depth                   : 32
        bytesperline            : 4096

window
    VIDIOCGWIN
        x                       : 0
        y                       : 0
        width                   : 0
        height                  : 0
        chromakey               : 0
        flags                   : 0

$ v4l-info /dev/video0
### video4linux device info [/dev/video0] ###
general info
    VIDIOCGCAP
    name                    : "DC10plus[0]"
    type                    : 0x29 [CAPTURE,OVERLAY,CLIPPING]
    channels                : 3
    audios                  : 0
    maxwidth                : 640
    maxheight               : 480
    minwidth                : 48
    minheight               : 32

channels
    VIDIOCGCHAN(0)
    channel                 : 0
    name                    : "Composite"
    tuners                  : 0
    flags                   : 0x0 []
    type                    : CAMERA
    norm                    : 1
    VIDIOCGCHAN(1)
    channel                 : 1
    name                    : "S-Video"
    tuners                  : 0
    flags                   : 0x0 []
    type                    : CAMERA
    norm                    : 1
    VIDIOCGCHAN(2)
    channel                 : 2
    name                    : "Internal/comp"
    tuners                  : 0
    flags                   : 0x0 []
    type                    : CAMERA
    norm                    : 1

tuner
ioctl VIDIOCGTUNER: Invalid argument

audio
ioctl VIDIOCGAUDIO: Invalid argument

picture
    VIDIOCGPICT
    brightness              : 32896
    hue                     : 32896
    colour                  : 33026
    contrast                : 33026
    whiteness               : 0
    depth                   : 16
    palette                 : YUYV

buffer
    VIDIOCGFBUF
    base                    : (nil)
    height                  : 768
    width                   : 1024
    depth                   : 32
    bytesperline            : 4096

window
    VIDIOCGWIN
    x                       : 0
    y                       : 0
    width                   : 0
    height                  : 0
    chromakey               : 0
    flags                   : 0

두가지를 다 리다이렉션은 하지만, 버퍼로 인해서 밀리는건가.. 아니면 다른 명령어가 있는걸까?
신고
Posted by 구차니

댓글을 달아 주세요

Linux2010.02.22 13:21
리다이렉션은, 데이터의 흐름(?)을 다른 곳으로 돌려주는 것을 의미한다.

일반적으로
fd = 0 은 stdin(입력)
fd = 1 은 stdout(표준출력)
fd = 2 는 stderr(표준에러출력)
으로 설정되는데, 이러한 출력을 다른 곳으로 돌려주는 역활을 한다.

예를들어,
에러만 파일에 저장하려면
make 2> err.log

일반메시지만 저장하려면
make > err.log

둘다 저장하려면
make > err.log 2>&1

으로 하면된다.

make 2>&1 err.log
라고 하면 에러가나니, 반드시 파일명과 함께 리다이렉션시킬 방향을 별도로 적어 주어야 한다.


REDIRECTION
       Before  a command is executed, its input and output may be redirected using a special notation interpreted by the
       shell.  Redirection may also be used to open and close files for the current shell  execution  environment.   The
       following  redirection  operators may precede or appear anywhere within a simple command or may follow a command.
       Redirections are processed in the order they appear, from left to right.

       In the following descriptions, if the file descriptor number is omitted, and the first character of the  redirec-
       tion  operator is <, the redirection refers to the standard input (file descriptor 0).  If the first character of
       the redirection operator is >, the redirection refers to the standard output (file descriptor 1).

       The word following the redirection operator in the following descriptions, unless otherwise noted,  is  subjected
       to  brace  expansion,  tilde  expansion,  parameter  expansion, command substitution, arithmetic expansion, quote
       removal, pathname expansion, and word splitting.  If it expands to more than one word, bash reports an error.

       Note that the order of redirections is significant.  For example, the command

              ls > dirlist 2>&1

       directs both standard output and standard error to the file dirlist, while the command

              ls 2>&1 > dirlist

       directs only the standard output to file dirlist, because the standard error was duplicated  as  standard  output
       before the standard output was redirected to dirlist.

[링크 : http://linux.die.net/man/1/bash]


신고

'Linux' 카테고리의 다른 글

diff의 -u 옵션 출력 내용 읽기 how read diff unified format?  (0) 2010.02.23
configure 관련 문서 모음  (0) 2010.02.23
bash 리다이렉션(redirection)  (0) 2010.02.22
리눅스 드라이버 / 모듈  (0) 2010.02.19
bash shell - TMOUT 환경변수  (0) 2010.02.18
chmod(3)  (0) 2010.02.18
Posted by 구차니

댓글을 달아 주세요