FAQ
I want to execute an "echo" command on windows - no sure how. I tried this:

package main

import (
   "log"
   "os/exec"
)

func main () {
    cmd := exec.Command("echo", "%ALLUSERSPROFILE%")
out, err := cmd.Output()
if err != nil {
log.Println(err.Error())
return
}
print(string(out))
}

'echo' (or echo.exe) cannot be found in the PATH - how do I go about
setting this up? (Obviously from a command prompt I can execute an echo
command)

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Brad Fitzpatrick at Apr 18, 2014 at 12:53 am
    I think echo is a shell built-in on Windows (in cmd.exe).

    Just do:

         fmt.Println(os.Getenv("ALLUSERSPROFILE"))


    On Thu, Apr 17, 2014 at 5:34 PM, Shmuel C wrote:

    I want to execute an "echo" command on windows - no sure how. I tried
    this:

    package main

    import (
    "log"
    "os/exec"
    )

    func main () {
    cmd := exec.Command("echo", "%ALLUSERSPROFILE%")
    out, err := cmd.Output()
    if err != nil {
    log.Println(err.Error())
    return
    }
    print(string(out))
    }

    'echo' (or echo.exe) cannot be found in the PATH - how do I go about
    setting this up? (Obviously from a command prompt I can execute an echo
    command)

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Shmuel C at Apr 18, 2014 at 1:37 am
    Thanks!
    On Thursday, April 17, 2014 8:53:22 PM UTC-4, bradfitz wrote:

    I think echo is a shell built-in on Windows (in cmd.exe).

    Just do:

    fmt.Println(os.Getenv("ALLUSERSPROFILE"))



    On Thu, Apr 17, 2014 at 5:34 PM, Shmuel C <scohen...@gmail.com<javascript:>
    wrote:
    I want to execute an "echo" command on windows - no sure how. I tried
    this:

    package main

    import (
    "log"
    "os/exec"
    )

    func main () {
    cmd := exec.Command("echo", "%ALLUSERSPROFILE%")
    out, err := cmd.Output()
    if err != nil {
    log.Println(err.Error())
    return
    }
    print(string(out))
    }

    'echo' (or echo.exe) cannot be found in the PATH - how do I go about
    setting this up? (Obviously from a command prompt I can execute an echo
    command)

    --
    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 <javascript:>.
    For more options, visit https://groups.google.com/d/optout.
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 18, '14 at 12:34a
activeApr 18, '14 at 1:37a
posts3
users2
websitegolang.org

2 users in discussion

Shmuel C: 2 posts Brad Fitzpatrick: 1 post

People

Translate

site design / logo © 2021 Grokbase