Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reroute stdout, stderr back to /dev/tty

I just ssh-ed to some remote server and found that stdout and stderr of all commands/processes I am trying to run in bash is redirected to somewhere. So, I got following questions

How to detect:

1) Which file stdout, stderr is beeing rerouted in Linux?

and

2) And how reroute by default stdout and stderr back to /dev/tty?

Thank you in advance.

like image 388
Sergey Avatar asked Jan 24 '12 21:01

Sergey


People also ask

How do I move stderr to Dev Null?

In Unix, how do I redirect error messages to /dev/null? You can send output to /dev/null, by using command >/dev/null syntax. However, this will not work when command will use the standard error (FD # 2). So you need to modify >/dev/null as follows to redirect both output and errors to /dev/null.

How can I redirect stdout and stderr?

Understanding the concept of redirections and file descriptors is very important when working on the command line. To redirect stderr and stdout , use the 2>&1 or &> constructs.

How do I redirect stdout and stderr to a file in Linux?

Redirecting stdout and stderr to a file: The I/O streams can be redirected by putting the n> operator in use, where n is the file descriptor number. For redirecting stdout, we use “1>” and for stderr, “2>” is added as an operator. We have created a file named “sample.


1 Answers

A command that should do literally what you asked for in (2) is

exec >/dev/tty 2>&1

But I suspect that your analysis of the problem is incorrect. It would be useful to see the output of ssh -v ... (where ... is whatever arguments you typed in your original ssh command).

like image 193
zwol Avatar answered Oct 19 '22 23:10

zwol