Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We're designing a shell in the browser that will stream everything that shell outputs. stdout, stderr, anything.

however, just as this little example would demonstrate to you,

git clone >./git.out 
cat ./git.out

most of the output is not given to ./git.out. here is little video, if you want to see what's happening

We need commands like 'top','git' to work, any ideas how to get them ?

(outputting into a file is for illustration purposes only, we will stream every line of output to another system, we know for top it wouldn't make sense but I hope my point is clear enough for the ones who can provide insight. thanks.)

share|improve this question
Are you looking for something like this from Attachmate. – Nunya Jul 3 '11 at 17:57
@nunya yes, but this is the last thing we'd want to do.. Requirements Reflection for the Web Clients: Web browser enabled for Java 1.5+ – Devrim Jul 3 '11 at 18:39
Something like script? – glenn jackman Jul 3 '11 at 19:07

Most programs have two outputs: stdout and stderr. stdout is where the "main" information goes. stderr is used for, well, errors. It's also used for various non-important output, and also things like user prompts sometimes.

To capture all of it, you need to redirect stderr to stdout.

somecmd arg1 arg2 arg3 >somefile 2>&1

Or to capture stderr to a seperate file:

somecmd arg1 arg2 arg3 >stdout.txt 2>stderr.txt

Be aware that it IS possible for a program to use other outputs than stdout / stderr. It can determine your console and basically "force" output there. However this is extremely uncommon, and the above will work in 99% of situations.

One thing to keep in mind if you redirect both stdout and stderr to the same file is that stdout and stderr buffer differently, so it won't look the same in a log file as it will on the screen (lines will be out of order). Also, for your specific instance, your output is going to look like garbage. git does a lot of terminal manipulation (for the progress indicator) and in a log file it's going to look pretty awful.


From man git-clone:

Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -q is specified. This flag forces progress status even if the standard error stream is not directed to a terminal

share|improve this answer
hey chris - unfortunately this is not capturing that 'garbage' we're after. It suppresses all the output (assuming it's a good thing) but log file has no garbage in it which is exactly what we want. Try: git clone >somefile 2>&1 your other version is the same. – Devrim Jul 3 '11 at 17:30
Ah yes, I'm getting that behavior too. I believe git is testing to see if stderr is a terminal. To force it, I just used --progress and it worked fine. – Chris Jul 3 '11 at 17:52
awesome! thanks.. is there a way to have this behavior for everything else ? (problem solved for git, but there are many other bash stuff that do the same) – Devrim Jul 3 '11 at 18:34
@Devrim: It honestly depends on the program. Some do like git here, some may even not let you disable that behavior. Others use ncurses which is whole other beast by itself. You'll have to do your homework on each problematic program. – Chris Jul 3 '11 at 18:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.