title: Define attributes of wget inside bash script
body: <p>I'm trying to set up attributes to wget at the start of the program to use them for all the wget instances.</p>
  
  <pre><code>WGET_LOG_FILE=path/to/wget_log
  USER_AGENT='Mozilla/5.0 (X11; Linux i686; rv:18.0) Gecko/20100101 Firefox/18.0x'
  
  WGET="wget -U $USER_AGENT -a $WGET_LOG_FILE --no-clobber --wait=2 --random-wait"
  
  $WGET www.webpage.com
  </code></pre>
  
  <p>The problem is that it ignores the log and directs everything to the output or gives an error of "path/to/wget_log doesn't exist", therefore I suppose it also ignores the User agent string... </p>
  
  <p>So what am I doing wrong? I've tried changing " to ' or $() ...</p>
  
  <p>The weird thing is that if I execute in the terminal:</p>
  
  <pre><code>wget -U $USER_AGENT -a $WGET_LOG_FILE --no-clobber --wait=2 --random-wait www.webpage.com
  </code></pre>
  
  <p>It works, so I'm guessing that it's executed in some subshell and that's why it doesn't get it.</p>
  
  <p>So the questions are:</p>
  
  <ol>
  <li>How to correctly set attributes to wget in a bash script? Answered by Chepner</li>
  <li>How to check if wget is using the user agent specified? Just wget any user agent check webpage such as: <a href="http://whatsmyuseragent.com/" rel="nofollow">http://whatsmyuseragent.com/</a></li>
  <li>Is 2 seconds a good wait rate to fetch webpages?</li>
  </ol>
  
  <p>Thanks</p>