liuyuqi-dellpc 2 years ago
parent
commit
491ac2b418
1 changed files with 4 additions and 18 deletions
  1. 4 18
      convert.go

+ 4 - 18
convert.go

@@ -1,30 +1,16 @@
 package main
 
 import (
-	"fmt"
 	"os/exec"
 )
 
 // exec command
 func doCommand(cmd string) {
-	fmt.Println(cmd)
-	cmdRes := exec.Command("libreoffice", "--headless", "--convert-to html", "*.doc", "--outdir", "output")
-	stdout, err := cmdRes.Output()
-	if err != nil {
-		fmt.Println(err.Error())
-		return
-	}
-	fmt.Print(string(stdout))
-	cmdRes2 := exec.Command("libreoffice", "--headless", "--convert-to html", "*.docx", "--outdir", "output")
-	stdout2, err2 := cmdRes2.Output()
-	if err2 != nil {
-		fmt.Println(err2.Error())
-		return
-	}
-	fmt.Print("finish.... result is:")
-	fmt.Print(string(stdout2))
+	_ = exec.Command("sh", "-c", cmd).Run()
+	
 }
 
 func main() {
-	doCommand("go get -u github.com/golang/protobuf/protoc-gen-go")
+	doCommand("libreoffice --headless --convert-to html *.doc --outdir output")
+	doCommand("libreoffice --headless --convert-to html *.docx --outdir output")
 }