Marina Vinograd
Marina Vinograd

Reputation: 55

Output command result to file

Windows cmd file has the following line

  wget "http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz" -P C:\temp >> dld.log

After executing the dld.log file is empty. What is wrong with output redirection? It is necessary that the output of wget execution is written to the dld.log file

Upvotes: 1

Views: 107

Answers (1)

user7818749
user7818749

Reputation:

wget redirects output to stderr mostly to split off from the results data.

So direct answer to to make the current redirect code work is to use 2>&1 to direct sterr stream to stdout as in:

(wget "http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz" -P "C:\temp")>>dld.log 2>&1

However, wget has log functions built in which makes more sense. The switch is --output-file

wget "http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz" -P "C:\temp" --output-file=dld.log

See the wget manual for more info.

Upvotes: 1

Related Questions