input comes from an JSON request which looks like
{
"inputString" : "\"C:\\Program Files (x86)\\7-Zip\\7z.exe\" x c:\\temp\\test.zip -oc:\\temp\\test"
}
package main
import (
"fmt"
"os/exec"
)
func main() {
//Input received will be of this format
var inputstring string = "\"C:\Program Files (x86)\7-Zip\7z.exe\" x c:\temp\firmware8.zip -oc:\temp\fw"
cmd := exec.Command("cmd", "/c", inputstring)
out, err := cmd.Output()
fmt.Println("doneee", string(out), "err", err)
}
输出 : "'\"C:\Program Files (x86)\7-Zip\7z.exe\
"'未被识别为内部或外部命令,\r\不可运行的程序或批处理文件。\r\n"
"C:\Program Files (x86)\7-Zip\7z.exe" xc:\temp\test.zip -oc:\temp\test - 我必须在命令提示符下运行此命令,但它只是在执行部分突出显示
由于输入字符串不是静态的(它来自 JSON),所以我们不能将它们拆分为参数
慕丝7291255
摇曳的蔷薇
相关分类