I am trying to run cqlsh shell command 'COPY' from golang, but it is always exit status 2.
cmd := "/path/to/my/cqlsh"
args := []string{`ipaddress -e "COPY keyspace.table (cl1, cl2) to /path/to/file"`}
exec.Command(cmd, args...).Run()
This always run into error.
When you pass in your arguments they need to be properly formatted, meaning you can't pass them in together as a single string. You also need to escape the quotation marks for the CQL command so the entire command is considered a single command line argument.
The args should look something like this:
args := []string{"ipaddress", "-e", "\"COPY keyspace.table (cl1, cl2) to /path/to/file\""}