title: Error when running curl inside script (No such file or directory)
body: <p>I have the following .sh file I pieced together off of things I found on the internet.<br>
  The goal is to read the 2nd line 2nd item in a CSV file and use that to send a delete commmand to elasticsearch.</p>
  
  <pre><code>#!/bin/sh
  OLDIFS=$IFS
  IFS=,
  
  
  function quit {
          echo "Quitting Script"
          IFS=$OLDIFS
      exit 1
  }
  function fileExists {
      if [ ! -f "$1" ]
          then
              echo "File $1 does not exists"
                  quit
          fi
  echo "File Name:  $1"
  }
  function work {
          linesToSkip=1
          {
              for ((i=$linesToSkip;i--;)) ;do
                  read
              done
                  #Read 2nd item of the 2nd line of CSV file to get PROGRAMURL
              read INDEX PROGRAMURL JUNK
                  echo "$PROGRAMURL"
                  QUERY="curl -XDELETE http://127.0.0.1:9200/cj/_query  -d '{ \"query\" : { \"match\" : { \"PROGRAMURL\" : "$PROGRAMURL" } } }'"
                  $("$QUERY")
                  #RESPONSE=`$QUERY`
                  #echo $RESPONSE
  
          } &lt; $1
  
  }
  
  fileExists $1
  work $1
  IFS=$OLDIFS
  </code></pre>
  
  <p>Everything works except the execution of the curl script.  I've tried it with $(), backtics, exec, and I cannot get it to work.</p>
  
  <p>The following is the error when I run bash -vx script.sh:</p>
  
  <pre><code>bash -vx ./deleteExisting.sh catalog.csv
  #!/bin/sh
  OLDIFS=$IFS
  + OLDIFS='  
  '
  IFS=,
  + IFS=,
  
  
  function quit {
      echo "Quitting Script"
      IFS=$OLDIFS
      exit 1
  }
  function fileExists {
      if [ ! -f "$1" ]
      then
          echo "File $1 does not exists"
          quit
      fi  
  echo "File Name:  $1"
  }
  function work {
      linesToSkip=1
      {
          for ((i=$linesToSkip;i--;)) ;do
              read
          done
          #Read 2nd item of the 2nd line of CSV file to get PROGRAMURL
          read INDEX PROGRAMURL JUNK
          echo "$PROGRAMURL"
          QUERY="curl -XDELETE http://127.0.0.1:9200/cj/_query  -d '{ \"query\" : { \"match\" : { \"PROGRAMURL\" : "$PROGRAMURL" } } }'"
          $("$QUERY")
          #RESPONSE=`$QUERY`
          #echo $RESPONSE
  
      } &lt; $1  
  
  }
  
  fileExists $1
  + fileExists catalog.csv
  + '[' '!' -f catalog.csv ']'
  + echo 'File Name:  catalog.csv'
  File Name:  catalog.csv
  work $1
  + work catalog.csv
  + linesToSkip=1
  + (( i=1 ))
  + (( i-- ))
  + read
  + (( 1 ))
  + (( i-- ))
  + read INDEX PROGRAMURL JUNK
  + echo '"http://www.website.com"'
  "http://www.website.com"
  + QUERY='curl -XDELETE http://127.0.0.1:9200/cj/_query  -d '\''{ "query" : { "match" : { "PROGRAMURL" : "http://www.website.com" } } }'\'''
  "$QUERY")
  "$QUERY"
  ++ 'curl -XDELETE http://127.0.0.1:9200/cj/_query  -d '\''{ "query" : { "match" : { "PROGRAMURL" : "http://www.website.com" } } }'\'''
  ./deleteExisting.sh: line 29: curl -XDELETE http://127.0.0.1:9200/cj/_query  -d '{ "query" : { "match" : { "PROGRAMURL" : "http://www.website.com" } } }': No such file or directory
  IFS=$OLDIFS 
  + IFS='     
  '
  </code></pre>
  
  <p>Example CSV file would be</p>
  
  <pre><code>INDEX, PROGRAMURL, other, info
  "1", "http://website.com", "other info", "information"
  </code></pre>