How to capture a changing one line program output?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
A program outputs various data lines to the same line in a timely order, overwriting the line in each line write. How can I capture all of its output lines and write them to a file separated by newlines?
Regular redirection would not do it.
io-redirection windows-subsystem-for-linux
 |Â
show 5 more comments
up vote
0
down vote
favorite
A program outputs various data lines to the same line in a timely order, overwriting the line in each line write. How can I capture all of its output lines and write them to a file separated by newlines?
Regular redirection would not do it.
io-redirection windows-subsystem-for-linux
Regular redirection would not do it. Have you tried? The data will be in the file anyway.
â Andrew Henle
Apr 10 at 14:55
Yes I have tried. The program removes all of its output in the end and so even if something could have been written it would still get overwritten with blank.
â elig
Apr 10 at 15:13
The program removes all of its output in the end How do you know? Did you simply redirect output to a file, thencat
that file?
â Andrew Henle
Apr 10 at 15:17
No. I watched it in my terminal. It displays a few lines replaced going on for a few seconds and then it erases back to the start and a bash prompt reappears in the beginning of the line like the program never ran.
â elig
Apr 10 at 15:18
No. I watched it in my terminal. So, you've never actually tried redirection? That means you don't really know whether or not redirection actually works.
â Andrew Henle
Apr 10 at 15:20
 |Â
show 5 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
A program outputs various data lines to the same line in a timely order, overwriting the line in each line write. How can I capture all of its output lines and write them to a file separated by newlines?
Regular redirection would not do it.
io-redirection windows-subsystem-for-linux
A program outputs various data lines to the same line in a timely order, overwriting the line in each line write. How can I capture all of its output lines and write them to a file separated by newlines?
Regular redirection would not do it.
io-redirection windows-subsystem-for-linux
edited Apr 10 at 15:25
Stephen Kitt
140k22305365
140k22305365
asked Apr 10 at 14:50
elig
215
215
Regular redirection would not do it. Have you tried? The data will be in the file anyway.
â Andrew Henle
Apr 10 at 14:55
Yes I have tried. The program removes all of its output in the end and so even if something could have been written it would still get overwritten with blank.
â elig
Apr 10 at 15:13
The program removes all of its output in the end How do you know? Did you simply redirect output to a file, thencat
that file?
â Andrew Henle
Apr 10 at 15:17
No. I watched it in my terminal. It displays a few lines replaced going on for a few seconds and then it erases back to the start and a bash prompt reappears in the beginning of the line like the program never ran.
â elig
Apr 10 at 15:18
No. I watched it in my terminal. So, you've never actually tried redirection? That means you don't really know whether or not redirection actually works.
â Andrew Henle
Apr 10 at 15:20
 |Â
show 5 more comments
Regular redirection would not do it. Have you tried? The data will be in the file anyway.
â Andrew Henle
Apr 10 at 14:55
Yes I have tried. The program removes all of its output in the end and so even if something could have been written it would still get overwritten with blank.
â elig
Apr 10 at 15:13
The program removes all of its output in the end How do you know? Did you simply redirect output to a file, thencat
that file?
â Andrew Henle
Apr 10 at 15:17
No. I watched it in my terminal. It displays a few lines replaced going on for a few seconds and then it erases back to the start and a bash prompt reappears in the beginning of the line like the program never ran.
â elig
Apr 10 at 15:18
No. I watched it in my terminal. So, you've never actually tried redirection? That means you don't really know whether or not redirection actually works.
â Andrew Henle
Apr 10 at 15:20
Regular redirection would not do it. Have you tried? The data will be in the file anyway.
â Andrew Henle
Apr 10 at 14:55
Regular redirection would not do it. Have you tried? The data will be in the file anyway.
â Andrew Henle
Apr 10 at 14:55
Yes I have tried. The program removes all of its output in the end and so even if something could have been written it would still get overwritten with blank.
â elig
Apr 10 at 15:13
Yes I have tried. The program removes all of its output in the end and so even if something could have been written it would still get overwritten with blank.
â elig
Apr 10 at 15:13
The program removes all of its output in the end How do you know? Did you simply redirect output to a file, then
cat
that file?â Andrew Henle
Apr 10 at 15:17
The program removes all of its output in the end How do you know? Did you simply redirect output to a file, then
cat
that file?â Andrew Henle
Apr 10 at 15:17
No. I watched it in my terminal. It displays a few lines replaced going on for a few seconds and then it erases back to the start and a bash prompt reappears in the beginning of the line like the program never ran.
â elig
Apr 10 at 15:18
No. I watched it in my terminal. It displays a few lines replaced going on for a few seconds and then it erases back to the start and a bash prompt reappears in the beginning of the line like the program never ran.
â elig
Apr 10 at 15:18
No. I watched it in my terminal. So, you've never actually tried redirection? That means you don't really know whether or not redirection actually works.
â Andrew Henle
Apr 10 at 15:20
No. I watched it in my terminal. So, you've never actually tried redirection? That means you don't really know whether or not redirection actually works.
â Andrew Henle
Apr 10 at 15:20
 |Â
show 5 more comments
1 Answer
1
active
oldest
votes
up vote
2
down vote
Assuming this is done using r
, which returns the cursor to the beginning of the current line without moving to the next line, and that the program in question is sending its output to its standard output, converting all the r
characters in the programâÂÂs output to n
will produce the result youâÂÂre after:
yourprogram | tr 'r' 'n' > logfile
See the difference between
printf "Hellorworldn"
and
printf "Hellorworldn" | tr 'r' 'n'
Note that without this, redirecting to a log file will store all the output in the file; youâÂÂd be able to see it by viewing the file using less
rather than cat
. (less
will show r
as ^M
, without overwriting the previous line.)
If the program is writing directly to the terminal, this wonâÂÂt help. In that case, youâÂÂll need to use a program capable of capturing all the terminal output too; one example is script
:
script -c yourprogram logfile
will start the program and capture all its output to logfile
. YouâÂÂll need to process the special characters in the logfile to make sense of it â less
will help you there (or any reasonable editor).
Unfortunately, this does not work. Running the first command without redirection it eliminates the output to stdout at all. And with redirection the file gets empty.
â elig
Apr 10 at 15:16
It occurred to me that this might be an issue â see my update.
â Stephen Kitt
Apr 10 at 15:19
Wait â do you want to see the output while itâÂÂs being logged?
â Stephen Kitt
Apr 10 at 15:20
i don't mind. I use WSL so I cannot use script. See: superuser.com/questions/1249475/â¦
â elig
Apr 10 at 15:23
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Assuming this is done using r
, which returns the cursor to the beginning of the current line without moving to the next line, and that the program in question is sending its output to its standard output, converting all the r
characters in the programâÂÂs output to n
will produce the result youâÂÂre after:
yourprogram | tr 'r' 'n' > logfile
See the difference between
printf "Hellorworldn"
and
printf "Hellorworldn" | tr 'r' 'n'
Note that without this, redirecting to a log file will store all the output in the file; youâÂÂd be able to see it by viewing the file using less
rather than cat
. (less
will show r
as ^M
, without overwriting the previous line.)
If the program is writing directly to the terminal, this wonâÂÂt help. In that case, youâÂÂll need to use a program capable of capturing all the terminal output too; one example is script
:
script -c yourprogram logfile
will start the program and capture all its output to logfile
. YouâÂÂll need to process the special characters in the logfile to make sense of it â less
will help you there (or any reasonable editor).
Unfortunately, this does not work. Running the first command without redirection it eliminates the output to stdout at all. And with redirection the file gets empty.
â elig
Apr 10 at 15:16
It occurred to me that this might be an issue â see my update.
â Stephen Kitt
Apr 10 at 15:19
Wait â do you want to see the output while itâÂÂs being logged?
â Stephen Kitt
Apr 10 at 15:20
i don't mind. I use WSL so I cannot use script. See: superuser.com/questions/1249475/â¦
â elig
Apr 10 at 15:23
add a comment |Â
up vote
2
down vote
Assuming this is done using r
, which returns the cursor to the beginning of the current line without moving to the next line, and that the program in question is sending its output to its standard output, converting all the r
characters in the programâÂÂs output to n
will produce the result youâÂÂre after:
yourprogram | tr 'r' 'n' > logfile
See the difference between
printf "Hellorworldn"
and
printf "Hellorworldn" | tr 'r' 'n'
Note that without this, redirecting to a log file will store all the output in the file; youâÂÂd be able to see it by viewing the file using less
rather than cat
. (less
will show r
as ^M
, without overwriting the previous line.)
If the program is writing directly to the terminal, this wonâÂÂt help. In that case, youâÂÂll need to use a program capable of capturing all the terminal output too; one example is script
:
script -c yourprogram logfile
will start the program and capture all its output to logfile
. YouâÂÂll need to process the special characters in the logfile to make sense of it â less
will help you there (or any reasonable editor).
Unfortunately, this does not work. Running the first command without redirection it eliminates the output to stdout at all. And with redirection the file gets empty.
â elig
Apr 10 at 15:16
It occurred to me that this might be an issue â see my update.
â Stephen Kitt
Apr 10 at 15:19
Wait â do you want to see the output while itâÂÂs being logged?
â Stephen Kitt
Apr 10 at 15:20
i don't mind. I use WSL so I cannot use script. See: superuser.com/questions/1249475/â¦
â elig
Apr 10 at 15:23
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Assuming this is done using r
, which returns the cursor to the beginning of the current line without moving to the next line, and that the program in question is sending its output to its standard output, converting all the r
characters in the programâÂÂs output to n
will produce the result youâÂÂre after:
yourprogram | tr 'r' 'n' > logfile
See the difference between
printf "Hellorworldn"
and
printf "Hellorworldn" | tr 'r' 'n'
Note that without this, redirecting to a log file will store all the output in the file; youâÂÂd be able to see it by viewing the file using less
rather than cat
. (less
will show r
as ^M
, without overwriting the previous line.)
If the program is writing directly to the terminal, this wonâÂÂt help. In that case, youâÂÂll need to use a program capable of capturing all the terminal output too; one example is script
:
script -c yourprogram logfile
will start the program and capture all its output to logfile
. YouâÂÂll need to process the special characters in the logfile to make sense of it â less
will help you there (or any reasonable editor).
Assuming this is done using r
, which returns the cursor to the beginning of the current line without moving to the next line, and that the program in question is sending its output to its standard output, converting all the r
characters in the programâÂÂs output to n
will produce the result youâÂÂre after:
yourprogram | tr 'r' 'n' > logfile
See the difference between
printf "Hellorworldn"
and
printf "Hellorworldn" | tr 'r' 'n'
Note that without this, redirecting to a log file will store all the output in the file; youâÂÂd be able to see it by viewing the file using less
rather than cat
. (less
will show r
as ^M
, without overwriting the previous line.)
If the program is writing directly to the terminal, this wonâÂÂt help. In that case, youâÂÂll need to use a program capable of capturing all the terminal output too; one example is script
:
script -c yourprogram logfile
will start the program and capture all its output to logfile
. YouâÂÂll need to process the special characters in the logfile to make sense of it â less
will help you there (or any reasonable editor).
edited Apr 10 at 15:16
answered Apr 10 at 14:54
Stephen Kitt
140k22305365
140k22305365
Unfortunately, this does not work. Running the first command without redirection it eliminates the output to stdout at all. And with redirection the file gets empty.
â elig
Apr 10 at 15:16
It occurred to me that this might be an issue â see my update.
â Stephen Kitt
Apr 10 at 15:19
Wait â do you want to see the output while itâÂÂs being logged?
â Stephen Kitt
Apr 10 at 15:20
i don't mind. I use WSL so I cannot use script. See: superuser.com/questions/1249475/â¦
â elig
Apr 10 at 15:23
add a comment |Â
Unfortunately, this does not work. Running the first command without redirection it eliminates the output to stdout at all. And with redirection the file gets empty.
â elig
Apr 10 at 15:16
It occurred to me that this might be an issue â see my update.
â Stephen Kitt
Apr 10 at 15:19
Wait â do you want to see the output while itâÂÂs being logged?
â Stephen Kitt
Apr 10 at 15:20
i don't mind. I use WSL so I cannot use script. See: superuser.com/questions/1249475/â¦
â elig
Apr 10 at 15:23
Unfortunately, this does not work. Running the first command without redirection it eliminates the output to stdout at all. And with redirection the file gets empty.
â elig
Apr 10 at 15:16
Unfortunately, this does not work. Running the first command without redirection it eliminates the output to stdout at all. And with redirection the file gets empty.
â elig
Apr 10 at 15:16
It occurred to me that this might be an issue â see my update.
â Stephen Kitt
Apr 10 at 15:19
It occurred to me that this might be an issue â see my update.
â Stephen Kitt
Apr 10 at 15:19
Wait â do you want to see the output while itâÂÂs being logged?
â Stephen Kitt
Apr 10 at 15:20
Wait â do you want to see the output while itâÂÂs being logged?
â Stephen Kitt
Apr 10 at 15:20
i don't mind. I use WSL so I cannot use script. See: superuser.com/questions/1249475/â¦
â elig
Apr 10 at 15:23
i don't mind. I use WSL so I cannot use script. See: superuser.com/questions/1249475/â¦
â elig
Apr 10 at 15:23
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436794%2fhow-to-capture-a-changing-one-line-program-output%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Regular redirection would not do it. Have you tried? The data will be in the file anyway.
â Andrew Henle
Apr 10 at 14:55
Yes I have tried. The program removes all of its output in the end and so even if something could have been written it would still get overwritten with blank.
â elig
Apr 10 at 15:13
The program removes all of its output in the end How do you know? Did you simply redirect output to a file, then
cat
that file?â Andrew Henle
Apr 10 at 15:17
No. I watched it in my terminal. It displays a few lines replaced going on for a few seconds and then it erases back to the start and a bash prompt reappears in the beginning of the line like the program never ran.
â elig
Apr 10 at 15:18
No. I watched it in my terminal. So, you've never actually tried redirection? That means you don't really know whether or not redirection actually works.
â Andrew Henle
Apr 10 at 15:20