Skip to content

os/exec: Command doesn't seem to work as I expected #14632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rdeusser opened this issue Mar 4, 2016 · 3 comments
Closed

os/exec: Command doesn't seem to work as I expected #14632

rdeusser opened this issue Mar 4, 2016 · 3 comments

Comments

@rdeusser
Copy link

rdeusser commented Mar 4, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

    1.6

  2. What operating system and processor architecture are you using (go env)?

    GOARCH="amd64"
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"

  3. 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

  4. 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.

  5. 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.

@bradfitz 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 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
@bradfitz
Copy link
Contributor

bradfitz commented Mar 4, 2016

Your shell is doing argument parsing for you. Try removing the double quotes.

@bradfitz bradfitz closed this as completed Mar 4, 2016
@rdeusser
Copy link
Author

rdeusser commented Mar 4, 2016

I've updated the example with what I think you mean @bradfitz: https://play.golang.org/p/fF3xTONlIq

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.

@minux
Copy link
Member

minux commented Mar 4, 2016 via email

@golang golang locked and limited conversation to collaborators Mar 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants