I have a space path from Windows 001 .video.mp4.enc, but exec.Command not working when remove space 001.video.mp4.enc it's work,
cmdPromp := "cmd.exe"
command := "openssl smime -decrypt -in C:\dataencrypt\001 .video.mp4.enc -inform DER -inkey key/key.private -out datadecrypt/001 .video.mp4 -binary"
arg := []string{"/c", command}
cmd := exec.Command(cmdPromp, arg...)
Is there a solution to this problem?
CodePudding user response:
Either rename the files, or use quotation marks around the file names.
command := `openssl smime -decrypt -in C:\dataencrypt\001 " .video.mp4.enc" -inform DER -inkey key/key.private -out datadecrypt/001 " .video.mp4" -binary`
Incidentally, it is probably best to use backtick quotes `` rather as than double quotes "" here as I have done, because Windows paths can look a lot to like backslashes that should be interpreted, e.g. \n is a new line, while backtick is the raw characters https://go101.org/article/basic-types-and-value-literals.html#string-literals
