How to convert Os.File output into string instead of printing to shell. I am using github.com/kr/pty library to execute commands.
How can convert the output to sting instead of printing to console.
f belongs to Os.File in below example. How to convert it to string.
package main
import (
"github.com/kr/pty"
"io"
"os"
"os/exec"
)
func run_command(cmd string){
c := exec.Command("/bin/sh", "-c", cmd)
f, err := pty.Start(c)
if err != nil {
panic(err)
}
io.Copy(os.Stdout, f)
}
func main() {
run_command("ls -lrt");
}