B
B
blajlhimik2020-10-23 15:10:38
go
blajlhimik, 2020-10-23 15:10:38

How to execute cmd command from go?

Got a team

D:\1c\8.3.9.2170\bin\1cv8.exe CREATEINFOBASE File="D:\_lang\go\gopath\src\peregruzki_assistant\local\cl1\db" /AddInList"cl1" /UseTemplate"D:\_lang\go\gopath\src\peregruzki_assistant\local\cl1\cf\rel.cf"

how to execute it from go?
exec.Command(path, args...)I tried each parameter separately, and exec.Command(command)tried it in its entirety, preferably without running the batch file to do this

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pavlyuk, 2020-10-23
@blajlhimik

cmd := exec.Command(`D:\1c\8.3.9.2170\bin\1cv8.exe`, "CREATEINFOBASE", `File="D:\_lang\go\gopath\src\peregruzki_assistant\local\cl1\db"`, `/AddInList"cl1"`, `/UseTemplate"D:\_lang\go\gopath\src\peregruzki_assistant\local\cl1\cf\rel.cf"`)
stdoutStderr, err := cmd.CombinedOutput()
if err != nil {
  log.Fatal(err)
}
fmt.Printf("%s\n", stdoutStderr)

exec.Command only creates a command, you still need to run it. There are several ways to start, I showed the simplest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question