You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What did you do?
(Use play.golang.org to provide a runnable example, if possible.)
Basically, I'm just calling ovftool with some arguments using exec.Command, but it's erroring out due to the way quotes are being passed in. Here's an example: https://play.golang.org/p/thL1dc3yxd
What did you expect to see?
This is what I get when ovftool is called via exec.Command:
Opening OVF source: "vsphere-ubuntu-14.04.4.vmx"
Error: Failed to open OVF descriptor
Completed with errors
But when the command is copy-pasted into the terminal, it works.
What did you see instead?
I expected it to work exactly like it would If I typed it in a terminal. I don't quite understand what is or isn't happening so I don't know if this is a Go problem or not.
The text was updated successfully, but these errors were encountered:
bradfitz
changed the title
exec.Command doesn't seem to work as it should
exec.Command doesn't seem to work as I expected
Mar 4, 2016
bradfitz
changed the title
exec.Command doesn't seem to work as I expected
os/exec: Command doesn't seem to work as I expected
Mar 4, 2016
If that is what you meant, then this will not work for me. Double quotes HAVE to be passed to the arguments in case of spaces (In my case there were no spaces). If that is not what you meant, please elaborate further.
os/exec doesn't parse the arguments for you, unlike C's system,
which uses shell to execute the command.
Given a command executed with shell:
command -A="a b c" "d e"
with os/exec, pass the following args to achieve the same effect:
[]string{ "-A=a b c", "d e" }
If the program really require the double-quotes, then at the shell
command line, you will need to do this:
command -A='"a b c"'
with os/exec, use this as args:
[]strings{ "-A=\"a b c\"" }
Please ask questions on mailing lists or forums, see
https://golang.org/wiki/Questions. Thanks.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.6
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
What did you do?
(Use play.golang.org to provide a runnable example, if possible.)
Basically, I'm just calling ovftool with some arguments using exec.Command, but it's erroring out due to the way quotes are being passed in. Here's an example: https://play.golang.org/p/thL1dc3yxd
What did you expect to see?
This is what I get when ovftool is called via exec.Command:
Opening OVF source: "vsphere-ubuntu-14.04.4.vmx"
Error: Failed to open OVF descriptor
Completed with errors
But when the command is copy-pasted into the terminal, it works.
What did you see instead?
I expected it to work exactly like it would If I typed it in a terminal. I don't quite understand what is or isn't happening so I don't know if this is a Go problem or not.
The text was updated successfully, but these errors were encountered: