After some digging I can run Linux commands from go like this:
func main() {
lsCmd := exec.Command("ls")
lsOut, err := lsCmd.Output()
if err != nil {
panic(err)
}
fmt.Println(">ls")
fmt.Println(string(lsOut))
}
What I want to do is, running following command in remote machine:
ssh -p $someport $someuser@$someip 'ls'
I can do this successfully from my terminal, but when I try to run it within Go, I get following error:
panic: exec: "ssh -p $someport $someuser@$someip 'ls'": executable file not found in $PATH
Update: I updated the question for convenience.