[lug] Bash shell script question

BC bcarr at purgatoire.org
Wed Feb 21 18:25:14 MST 2018


My Go code doesn't look remotely like yours, but I do remember seeing 
an os.Cmd structure that takes the environment into account. I 
experimented and found I didn't need to use that form.  But I'll go 
back and take another gander at it, just to be sure.  Go's slices are 
wonderful, aren't they?


On 2/21/2018 6:17 PM, Lee Woodworth wrote:
>
> Oh. And when building command lines for os.Cmd make sure you have 
> separate
> slice elements for each arg so they will be passed as separate args 
> to the
> command:
>
>     property := "the prop string"
>     tmpdir := "value for TMPDIR in the passed environment"
>     cmd := &exec.Cmd{
>         Path:       "/path/to/_get_jail_prop",
>         Dir:        "/cd/to/this/dir/,
>         Args:       []string{
>                        "/path/to/_get_jail_prop",
>                        property,
>                        "default",
>                     },
>         Env:        []string{
>                        "PATH=/usr/local/bin:/usr/bin",
>                        "TMPDIR=" + tmpdir,
>                     },
>     }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20180221/090775fd/attachment.html>


More information about the LUG mailing list