I found this easier:created exec.bash========================#exec.bash========================exec $1 $2 $3 $4 $5 $6 $7 $8 $9========================
in Go program:========================script := "sv s /etc/service/*"cmd1 := exec.Command("sudo", runPath+"./exec.bash", script)========================
This is working but cannot handle pipes.--ConstantineOn Wednesday, October 2, 2013 10:39:42 AM UTC-7, Ian Lance Taylor wrote:On Wed, Oct 2, 2013 at 10:29 AM, Constantine Vasil <ths...@gmail.com> wrote:
> I need to execute this command:
> sv s /etc/service/*
>
> In exec.Command it is:
> cmd1 := exec.Command("sv", "s" , "/etc/service/*")
> out, err := cmd1.Output()
>
> But I get an error message:
> fail: /etc/service/*: unable to change to service directory: file does not
> exist
>
> How to execute commands with path as argument?
On Unix systems, when you type a command like "sv s /etc/service/*"
into the shell, it is the shell that expands the *. To do this from
Go you will need to either expand the * yourself using filepath.Glob,
or you will need to do something like (untested)
exec.Command("/bin/sh", "-c", "sv s /etc/service/*")
Ian
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
but the less hackish way is to do it like this:exec.Command("sudo", "bash", "-c", "your full command including spaces here")