title: Using sftp << INPUT via golang os/exec
body: <p>What I want to do is exporting a file from my server via SFTP, in golang.</p>
  
  <p>Here is the troubling code</p>
  
  <pre><code>cmd = exec.Command("sftp", "login@sftp.com", `INPUT
      cd /some/path
      put file.gz
      quit
      INPUT`)
  cmd.Stderr = &amp;stderr
  err = cmd.Run()
  if err != nil {
      fmt.Println(stderr.String())
      os.Exit(1)
  }
  fmt.Println("done")
  </code></pre>
  
  <p>It gets to <code>done</code> but doesn't import <code>file.gz</code>. </p>