쉘상에서 stdout만 다른 터미널로 변경하는방법 질문.

mogin1의 이미지

제목그대로 쉘상에서 stdout만 다른터미널로 변경하는 방법이 있을까요?

또, A터미널과 B터미널에서 서로 연결되어 stdout출력될때 A,B둘다 출력되며 stdin도 두곳에서 입력방법

도 있는지 궁금하네요.

ymir의 이미지

$ ls -al > /dev/tty1

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

익명 사용자의 이미지


다른 터미널에서 두사람이 동시에 같은 화면을 보고 작업을 하는게 목적이시라면,

screen이나 tmux를 써서 같은 화면을 attach해서 보면 됩니다.

그렇게 하면, 화면 출력, 키보드 입력 모두 공유하게 됩니다.

mogin1의 이미지

stdin과 stdout을 분리하고싶어서입니다.

제가 보유중인 임베디드 개발보드 상에 uart시리얼은 ttySAC0고, 개발보드LCD쪽은 tty1로 되있는 상태 입니다.

tty1로 터미널을 설정해놨을경우, 입력(stdin)을 uart시리얼 포트(ttySAC0)에서 받을수 있도록 하기 위해서입니다.
ymir님께서 알려주신방법은 명령을 수행할때마다 redirection을 해줘야하는 경우가 아닌 stdout,in을 각각 다른 터미널로 분리하고자합니다.

ymir의 이미지

단순히 redirect 가 된다는 것은 device 에 직접 쓰기가 된다는 뜻이니..
다음과 같은 트릭을 쓸 수도 있다는 뜻입니다.

#include <stdio.h>
 
int main(void)
{
        FILE *fp = freopen("/dev/tty1", "a", stdout);
 
        printf("hello\r\n");
        printf("world\r\n");
 
        fclose(fp);
 
        return 0;
}

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

mogin1의 이미지

답변 감사 드립니다.
혹시 프로그래밍상이 아닌 bash쉘 상태에서 stdout만 redirection시키는 명령어가 있는지요?
stdout터미널에 상태프롬프트 까지([mogin@localhost linux-2.6.33]$)를 전부 출력하고자 합니다.

ymir의 이미지

프롬프트 까지는 모르겠네요.

위에서 말씀하신 screen 이나 tmux 에 그런 기능이 있는지 확인해 보시는게 빠를 수도 있겠습니다.

bash 의 stdout 을 redirect 시키는 건..

$ exec 1> /dev/tty1
$ ls -al && echo ls finished ..

처럼 exec 으로 fd 를 redirect 시켜 버리면 됩니다.

그럼 현재 쉘에서 실행한 명령의 모든 stdout 은 /dev/tty1 으로 날아갑니다.

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.