Redirecting exact output to a file
Hi all, I'm trying to redirect output of a script to a file. But output in file differs from what has been shown on screen.
Is there any way to redirect exact screen output to a file? As the hardest part of my problem, I'm using wget to download 999,999,999 files and I want to have the output in a file(then I'm processing these data), but each percentage of download which is completed is shown in file for several time, I want the exact output of screen to a file. |
|
using
Code:
wget http://speedtest.wdc01.softlayer.com/downloads/test500.zip > a.txt Code:
wget http://speedtest.wdc01.softlayer.com/downloads/test500.zip 1> a.txt and Code:
wget http://speedtest.wdc01.softlayer.com/downloads/test500.zip 2> a.txt Any help? |
Code:
wget http://speedtest.wdc01.softlayer.com/downloads/test500.zip &> ./output.txt You must use the &> to redirect both stdout and stderr. You should always check the man page too as most have redirect options built in. -o ./output.txt would work just fine for wget. |
Thanks for your answer, but still the same problem exists with both of them.
|
Then you are not seeing either stdout or stderr you either need to be more specific or what you are seeing cannot be redirected(which should be impossible but some ncurses and other things could be a factor).
|
For time it differs.
Also for wget, here is the result: Code:
$ wget http://speedtest.wdc01.softlayer.com/downloads/test500.zip and Code:
$ wget http://speedtest.wdc01.softlayer.com/downloads/test500.zip &> ./output.txt |
So your only issue is the pretty bar that it draws out showing your download progress? You will have to deal with that. Your redirection is working as intended.
|
If you are also concerned that your download times are slightly different, that is the way the internet works. Your speed is never going to be 100% the same, however it should stay within a relative range.
|
There is a difference between being connected to a terminal and sending output to a file, as the man page of wget states:
Quote:
Code:
wget --progress=bar:force -o output.txt http://speedtest.wdc01.softlayer.com/downloads/test500.zip |
Quote:
It even records the <cr><lf> of the physical I/O for the end of lines. |
based on my understanding of your problem statement : content of log file differs from console output.
Try tee <command> | tee /tmp/log -- to create /tmp/log or null existing file /tmp/log and write to it. <command> | tee -a /tmp.log -- to append output to file /tmp/log |
Tee works sometimes - It depends on whether the program tests for a real terminal or not and generates different output.
Tee is designed for use in a pipe (as shown), but not with some other applications (such as an editor). Even "ls" works differently - if the output is attached to a terminal then it will use a multi-column output with color highlighting. If it is attached to a pipe, then it outputs a single column, with no escape sequences for color highlighting. |
wget http://speedtest.wdc01.softlayer.com...ds/test500.zip > ./output.txt 2>&1
|
All times are GMT -5. The time now is 08:30 PM. |