Git Product home page Git Product logo

Comments (7)

Konstantin8105 avatar Konstantin8105 commented on May 29, 2024 1

How to run test for that issue:

go test -v -tags=integration -run=TestIntegrationScripts/tests/stdlib.c
go test -v -run=TestCSTD

from c4go.

Konstantin8105 avatar Konstantin8105 commented on May 29, 2024

example see #155

from c4go.

alebcay avatar alebcay commented on May 29, 2024

I'll take this! PR coming later today.

from c4go.

Konstantin8105 avatar Konstantin8105 commented on May 29, 2024

Try simplify code like that:
https://blog.kowalczyk.info/article/wOYk/advanced-command-execution-in-go-with-osexec.html

    cmd := exec.Command("ls", "-lah")
    var stdout, stderr bytes.Buffer
    cmd.Stdout = &stdout
    cmd.Stderr = &stderr
    err := cmd.Run()
    if err != nil {
        log.Fatalf("cmd.Run() failed with %s\n", err)
    }
    outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes())
    fmt.Printf("out:\n%s\nerr:\n%s\n", outStr, errStr)

from c4go.

alebcay avatar alebcay commented on May 29, 2024

That site is the example that I worked from, but I found that this only shows the output after the command finishes, which is not how the system function in C works. For example, a loop/other long running command will never show any output if we follow this example.

from c4go.

JalonSolov avatar JalonSolov commented on May 29, 2024

Saw this example on another site. It simply forces the output from the exec'd command to go directly to your stdout/stderr. No need to capture in a buffer and print it out after, and there is no delay in output.

cmd := exec.Command("ls", "-lah")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
	log.Fatalf("cmd.Run() failed with %s\n", err)
}

from c4go.

Konstantin8105 avatar Konstantin8105 commented on May 29, 2024

Dear @JalonSolov , feel free for creating PR.

from c4go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.