title: is there any way run multiple command "os/exec" in one proccess in golang?
body: <p>i want run multiple command in "os/exec" in one process, as you see below some command like "cd" not worked.</p>
  
  <pre><code>func main()  {
  cmd := exec.Command("ls")
  cmdOutput := &amp;bytes.Buffer{}
  cmd.Stdout = cmdOutput
  err := cmd.Run()
  fmt.Print(string(cmdOutput.Bytes()))
  
  fmt.Println("..........  cd   .........")
  cdOutput := &amp;bytes.Buffer{}
  cdcomand:=exec.Command("cd","model")
  cdcomand.Stdout = cdOutput
  err = cdcomand.Run()
  fmt.Print(string(cdOutput.Bytes()))
  fmt.Println(".......... ls .........")
  lsOutput := &amp;bytes.Buffer{}
  lscmd:=exec.Command("ls")
  lscmd.Stdout = lsOutput
  
  err = lscmd.Run()
  if err != nil {
      os.Stderr.WriteString(err.Error())
  }
  fmt.Print(string(lsOutput.Bytes()))}
  </code></pre>
  
  <p><br>
  i try with another way:
  <br>
      package main</p>
  
  <pre><code>import (
  "os/exec"
  "bytes"
  "os"
  "fmt"
  )
  
  func main()  {
  cmd := exec.Command("ls")
  cmdOutput := &amp;bytes.Buffer{}
  cmd.Stdout = cmdOutput
  err := cmd.Run()
  fmt.Print(string(cmdOutput.Bytes()))
  
  fmt.Println("..........  cd and ls   .........")
  cdOutput := &amp;bytes.Buffer{}
  cdcomand:= exec.Command("sh", "-c", "ls &amp;&amp; cd model")
  cdcomand.Stdout = cdOutput
  err = cdcomand.Run()
  fmt.Print(string(cdOutput.Bytes()))
  fmt.Println(".......... ls .........")
  lsOutput := &amp;bytes.Buffer{}
  lscmd:=exec.Command("ls")
  lscmd.Stdout = lsOutput
  
  err = lscmd.Run()
  if err != nil {
      os.Stderr.WriteString(err.Error())
  }
  fmt.Print(string(lsOutput.Bytes()))
  }
  </code></pre>
  
  <p>it did not work too.</p>
  
  <p>in cmd <a href="https://golang.org/pkg/os/exec/#Cmd" rel="nofollow noreferrer">document</a> writes: <br></p>
  
  <blockquote>
    <p>A Cmd cannot be reused after calling its Run, Output or CombinedOutput methods. </p>
  </blockquote>
  
  <p>i've searched all tuts and docs for a way to do this, but i could not find any things. there was no solution in <a href="https://zaiste.net/executing_external_commands_in_go/" rel="nofollow noreferrer">Executing external commands in Go</a> article and <a href="https://blog.kowalczyk.info/article/wOYk/advanced-command-execution-in-go-with-osexec.html" rel="nofollow noreferrer">advanced command execution in Go with os</a>
  <br></p>
  
  <p>each cmd command execute in different process so command like "cd" will not change directory .<br> is there any way run multiple command "os/exec" in one proccess in golang?  </p>