Without more information on what you have already tried, it's hard to give advice. Here's what I would try first:
some_program arg1 arg2 2>&1 | tee some_file
Output buffering can be an issue when a program's output that would normally go to a terminal is redirected somewhere else, such as to a pipe. Output that is going to a terminal is, by default, line buffered, whereas output (other than stderr) not going to a terminal is block buffered (typically 4KB blocks). That can result in messages and regular output not appearing in the same sequence they would when everything is going directly to a terminal. Workarounds for that depend on what program you are running, and include:
- In a C program, calling setbuf(3) to override the default buffering behavior,
- Using a specific flag argument to override buffering in programs that have that feature (e.g., the "--line-buffered" option in grep),
- Using the unbuffer utility (part of the expect package.