-1

i want to Redirect the output from a program to a file in Linux console. I found the soultion to use the ">" command . But it doesn`t work for me. I need the output during the runtime of the program not at the end of the runtime. Because the program streams the Progress (Percent) to stdout. I have no possibility to install new Tools to the Linux System.

The program does a update function:

**The expected Output is: ( The Perecent is moving during the program ((from 0 -100 %) )

# erase 
# load file XXX
# 100%
# erase 
# load file XXX
# 100%

only 100 Percent Information at the end of the program is recorded. Not while the program is running. For me its important to get the percent information while the program is runing and at the end. I want to visualize the Percent in a detached GUI.

user3707049
  • 65
  • 1
  • 1
  • 11
  • 3
    Please post some output from the said program and show what you'd like to do with which part of output. Also, show some work that you have done apart from _">" - - doesn't work for me_, – James Brown Oct 28 '16 at 12:57

2 Answers2

2

Have You tried piping to tee ? here are some examples.

echo "text" | tee /home/yourusername/file
bash somescript.sh | tee /home/yourusername/somescript.log
Farhad Farahi
  • 35,528
  • 7
  • 73
  • 70
  • 1
    @user3707049 You'll need to be a bit more specific if you want help with your problem. What do you mean by "does not work" ? Does it mean that your program doesn't display anything ? Or only when it is done executing ? Could you edit your original question to show how you call you program, how your program displays information and the output you have at the moment ? – Aserre Oct 28 '16 at 13:44
0

How about:

$ nohup program > output.txt ; tail -f output.txt
  • nohup runs program in the background redirecting it's output to a file
  • tail -f streams the end of the file on the screen

This of course means that you can't interact with the program while it's running.

James Brown
  • 36,089
  • 7
  • 43
  • 59