Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-28-2010, 12:54 PM   #1
Senior Member
Registered: May 2008
Distribution: Slackware
Posts: 1,033

Rep: Reputation: 69
How to redirect stdin and stderr to another terminal...

Is it possible to redirect stdout and stderr from one terminal say /dev/pts/2 to another /dev/pts/3?

I tried the following:
/dev/pts/2 2>&1 /dev/pts/3&
Then when I run a command the process stops.
Any ideas?

Last edited by trist007; 06-28-2010 at 02:00 PM.
Old 06-28-2010, 01:24 PM   #2
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,120

Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
what command output are you trying to redirect ?:
[schneidz@hyper ~]$ w
 14:21:44 up 14:23,  3 users,  load average: 0.08, 0.07, 0.01
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
schneidz tty1     :0               Sun23   14:23m 16:43   0.27s pam: gdm-password
schneidz pts/0    :0.0             09:22    1:10m  0.05s  0.05s bash
schneidz pts/1    :0.0             13:11    1.00s  0.22s  0.17s w
[schneidz@hyper ~]$ echo hello > /dev/pts/0
[schneidz@hyper ~]$ echo hello 2>&1 > /dev/pts/0
[schneidz@hyper ~]$ hello
Old 06-28-2010, 02:04 PM   #3
Senior Member
Registered: May 2008
Distribution: Slackware
Posts: 1,033

Original Poster
Rep: Reputation: 69
Trying to get the the output printing on Terminal A redirected to output on Terminal B.

Actually, I'm trying to redirect all stdout and stderr from terminal A to terminal B.

And then redirect stdin back from terminal B to terminal A.

Last edited by trist007; 06-28-2010 at 02:10 PM.
Old 06-29-2010, 02:22 AM   #4
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
here is the syntax:
ls /qwerty being the command (obviously something that will fail so you can see the effect of redirecting errors)

ls /qwerty >/dev/pts/4 2>&1

maybe you want to experiment with the screen command if you want to share with someone else a shell session
Old 06-29-2010, 08:10 AM   #5
Senior Member
Registered: May 2008
Distribution: Slackware
Posts: 1,033

Original Poster
Rep: Reputation: 69
Good stuff. Here's the situation I'm having.

I write a script. In this script, I pull a username from a database. I then userenv as that user. However, after I enter the user's password, it seems that stdin, stdout, and stderr are still printing to the tty that I was previously in before I completed the userenv command. I need to redirect those streams to the new tty that userenv opens.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script stdout, stderr and stdin solo9300 Linux - General 6 12-29-2009 12:33 AM
stdin redirect billysdomain Linux - Newbie 5 12-17-2009 02:03 PM
How to redirect stderr from piped output? redss Programming 2 08-21-2009 03:50 PM
how to change stdin, stdout & stderr in u-boot to ethernet from serial jynthms Linux - Newbie 1 04-01-2009 09:34 AM
how do i redirect stderr to a file? nodger Programming 5 11-28-2004 11:22 AM

All times are GMT -5. The time now is 03:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration