title: exec.Cmd is driving me insane
body: <p>The story is this: I have a program named coletorbeat that needs a large argument to run. This argument is built on a few parameters. I built a second program called bootstrapper that takes these parameters, builds the long argument required by coletorbeat and should then run coletorbeat, feeding it the long argument.
  I have tried multiple ways, with escaped quotes, backticks, and so on. But for some reason, the program is called and as if no argument had been passed at all. I don't even have an error message.
  I'll post the code below, any help is very much appreciated.</p>
  <p>Fields like coletorbeat.ip=%v should appear on the command line inside quotes or back-ticks, preceded by the flag -E.</p>
  <pre><code>package main
  
  import (
      &quot;fmt&quot;
      &quot;os&quot;
      &quot;os/exec&quot;
      &quot;time&quot;
  )
  
  func main() {
      if len(os.Args) &lt; 8 {
          fmt.Printf(&quot;%v arguments were given. 8 needed to work&quot;, len(os.Args))
          return
      }
      // Parâmetros devem ser passados na ordem: ip, porta, data_inicio, data_fim, tipo_equipamento, versao, nivel, instituicao
      //There can`t be empty spaces on any of the strings inside the Args. We gotta do some prevention in case it happens here.
  
      flag := &quot;-E&quot;
      Arg1 := fmt.Sprintf(&quot;`coletorbeat.ip=%v`&quot;, os.Args[1])
      Arg2 := fmt.Sprintf(&quot;`coletorbeat.porta=%v`&quot;, os.Args[2])
      Arg3 := fmt.Sprintf(&quot;`coletorbeat.dataInicio=%v`&quot;, os.Args[3])
      Arg4 := fmt.Sprintf(&quot;`coletorbeat.dataFim=%v`&quot;, os.Args[4])
      Arg5 := fmt.Sprintf(&quot;`coletorbeat.tipoEquipamento=%v`&quot;, os.Args[5])
      Arg6 := fmt.Sprintf(&quot;`coletorbeat.versao=%v`&quot;, os.Args[6])
      Arg7 := fmt.Sprintf(&quot;`coletorbeat.nivel=%v`&quot;, os.Args[7])
      Arg8 := fmt.Sprintf(&quot;`coletorbeat.instituicao=%v`&quot;, os.Args[8])
      Arg9 := fmt.Sprintf(&quot;`output.elasticsearch.index=collectorbeat-%v-%v-%v-%v`&quot;, os.Args[8], os.Args[5], time.Now().Format(&quot;20060201&quot;), os.Args[1])
  
      commandToExecute := &amp;exec.Cmd{
          Path: &quot;coletorbeat&quot;,
          Args: []string{&quot;./&quot;, flag, Arg1, flag, Arg2, flag, Arg3, flag, Arg4, flag, Arg5, flag, Arg6, flag, Arg7, flag, Arg8, flag, Arg9},       
          Stdout: os.Stdout,
          Stderr: os.Stdout,
      }
      fmt.Println(commandToExecute.Args)
      fmt.Println(&quot;Copy the code&quot;)
      if err := commandToExecute.Run(); err != nil {
          fmt.Println(&quot;error caught on Bootstrapper&quot;)
          fmt.Println(&quot;Error: &quot;, err)
      }
  }
  
  </code></pre>