Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In a bash script, I need to download a file from the web, for doing it i use wget command. I would log the output of wget command, and at "the same time" having the output prompting on terminal.

I searched in the man wget without find the way to achieve that.

it seems that if you turn on the log with -o or -a parameter, then the prompt output is automatically 'redirected' to the log file, and nothing is showed on terminal while executing the script, until it have done to download.

wget -a wget_log --no-check-certificate --auth-no-challenge --http-user=$jen_uname --http-password=$jen_psswd link_to_the_file

Is it possible to do both? output on prompt and writing on log file?

every hint is appreciated

share|improve this question
    
Just to be clear - you want the output of wget to go both to a log file and to the terminal? –  mjturner May 8 at 12:39
    
exactly. i will try to edit the question to be more clear. –  lese May 8 at 12:58
add comment

1 Answer 1

up vote 6 down vote accepted

You use the lovely tee command to do this:

wget --no-check-certificate --auth-no-challenge --http-user=$jen_uname --http-password=$jen_psswd 2>&1 | tee -a wget_log

THe 2>&1 means that STDERR goes to the same place as STDOUT, and they're both piped to tee. The -a means append. tee will then send the output both to wget_log and to STDOUT.

share|improve this answer
    
great! thankyou jenny for the clear explaination! –  lese May 8 at 14:47
add comment

Your Answer

 
discard

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.