2016-01-03 18:52 GMT+01:00 Sathish VJ <
sath...@gmail.com>:
> I'm attempting to run a unix command to retrieve the url that a short url
> evaluates to. It works if I run curl from the command line. But running it
> from within Go gives me a 400 Bad Request.
> cmdStr := fmt.Sprintf("%s -s -L -o /dev/null -w '%%{url_effective}'", shortUrl)
> out, err := exec.Command("curl", cmdStr).Output()
This needs to be split into something like
out, err := exec.Command("curl", shortUrl, "-s", "-L", ...) // etc
as you're not passing through a shell that does argument splitting.
But really, there's no reason to use curl from within Go, unless
you're just doing this to experiment with running external commands.
//jb