Archive for 4월 10th, 2008

푸념 - 현재 숙제 상태

목요일, 4월 10th, 2008

image

image

TSP(Traveling salesman problem)입니다.

이 그림이 멋지게 정리된 모양으로 나와야 되는데

수업중 배운 기본 알고리즘 가지고는 그다지 멋지게 나오지 않는군요 0.0

이제 이번주 나머지는 다른 과제 때문에 다음주에나 봐야 할 듯.

일단 돌아가는 게 어디냐.. -.-

(졸업한 친구가 예전 숙제할 때 화면에 그리는 자바 클래스를 만들어두었네요 매우 감사)

Shell Redirection

목요일, 4월 10th, 2008

http://www.cpqlinux.com/redirect.html

  • The following command saves stdout and stderr to the files “out.txt” and “err.txt”, respectively.
    [root@server /root]# ./cmd 1>out.txt 2>err.txt
  • The following command appends stdout and stderr to the files “out.txt” and “err.txt”, respectively.
    [root@server /root]# ./cmd 1>>out.txt 2>>err.txt
  • The following command functions similar to the above two commands, but also copies stdout and stderr to the files “stdout.txt” and “stderr.txt”, respectively.
    [root@server /root]# (((./cmd | tee stdout.txt) 3>&1 1>&2 2>&3\
    |tee stderr.txt) 3>&1 1>&2 2>&3) 1>out.txt 2>err.txt

    Note: Lines that end in a backslash are continued on the next line. Any such lines should be keyed in as one complete line. The lines are too long to fit on the web page without formatting them this way.

  • Capturing stdout
    The following will capture a copy of stdout and save it to a file called “stdout.txt”
    [root@server /root]# ./cmd | tee stdout.txt

    stdout goes through the pipe and tee is able to save a copy of it to the file “stdout.txt”; however, we just lost control of stderr. stderr will not go through the pipe, instead it goes directly to our display.

  • Gaining control of stderr and stdout.
    Lets gain control again of stderr and stdout. We do this by surrounding our command with a set of parenthesis.
    [root@server /root]# (./cmd | tee stdout.txt)

    Capturing stderr
    Now that we have swapped our stdout and stderr, lets hook up tee once again. tee will now capture stderr (tee believes that it is really stdout because stdout is the only thing that can come through the pipe).

    [root@server /root]# (./cmd | tee stdout.txt) 3>&1 1>&2 2>&3 \
    | tee stderr.txt