Skip to content

os/exec: the windows route command run failed with wrong output. #13995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iswarezwp opened this issue Jan 18, 2016 · 4 comments
Closed

os/exec: the windows route command run failed with wrong output. #13995

iswarezwp opened this issue Jan 18, 2016 · 4 comments

Comments

@iswarezwp
Copy link

The code:

package main

import (
    "fmt"
    "os/exec"
)

func main() {
    cmd := exec.Command("route", "ADD", "10.20.30.40", "MASK 255.255.255.255",
        "192.168.12.14")

    ret, err := cmd.CombinedOutput()
    if err != nil {
        fmt.Println(string(ret))
    }
}

I run this code under nomal and administrator model, and get the same result:

route:             192.168.12.14

Then I write some Python code:

import os

print(os.popen("route ADD 10.20.30.40 MASK 255.255.255.255 192.168.12.13").readlines()[0])

I got different result with different console model. And the output is just the same as I run the command directly.

@hirochachacha
Copy link
Contributor

wrong:

cmd := exec.Command("route", "ADD", "10.20.30.40", "MASK 255.255.255.255",
        "192.168.12.14")

correct:

cmd := exec.Command("route", "ADD", "10.20.30.40", "MASK", "255.255.255.255", "192.168.12.14")

wrong:

if err != nil {
   fmt.Println(string(ret))
}

correct:

if err != nil {
  panic(err)
}
fmt.Println(string(ret))

@hirochachacha
Copy link
Contributor

I think it's not a go's issue.

@iswarezwp
Copy link
Author

@hirochachacha I changed my code and the result is the same. Could you please run the test code on windows 7?

@iswarezwp
Copy link
Author

Sorry, It's my fault.

@golang golang locked and limited conversation to collaborators Jan 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants