title: Login via curl fails inside bash script, same curl succeeds on command line
body: <p>I'm running this login via curl in my bash script. I want to make sure I can login before executing the rest of the script, where I actually log in and store the cookie in a cookie jar and then execute another curl in the API thousands of times. I don't want to run all that if I've failed to login.</p>
  
  <p>Problem is, the basic login returns 401 when it runs inside the script. But when I run the exact same curl command on the command line, it returns 200!</p>
  
  <pre><code>basic_login_curl="curl -w %{http_code} -s -o /dev/null -X POST -d \"username=$username&amp;password=$password\" $endpoint/login"
  echo $basic_login_curl
  outcome=`$basic_login_curl`
  echo $outcome
  if [ "$outcome" == "401" ]; then
      echo "Failed login. Please try again."; exit 1;
  fi
  </code></pre>
  
  <p>This outputs:</p>
  
  <pre><code>curl -w %{http_code} -s -o /dev/null -X POST -d "username=bdunn&amp;password=xxxxxx" http://stage.mysite.it:9301/login
  401
  Failed login. Please try again.
  </code></pre>
  
  <p>Copied the output and ran it on the cmd line:</p>
  
  <pre><code>$ curl -w %{http_code} -s -o /dev/null -X POST -d "username=bdunn&amp;password=xxxxxx" http://stage.mysite.it:9301/login
  200$
  </code></pre>
  
  <p>Any ideas? LMK if there's more from the code you need to see.</p>
  
  <p>ETA: Please note: The issue's not that it doesn't match 401, it's that running the same curl login command inside the script fails to authenticate, whereas it succeeds when I run it on the actual CL.</p>