Running curl bash command in go and reading live output

Hello Sir, i want to run some curl bash scripts via golang want to show that script’s realtime output to the user.
for example,
i want to runcurl -Lso- bench.sh | bash
in golang and show realtime output to the user, how can i do this?
i have tried these :-

actually, i want to run some bash scripts and some binary files via golang and show the output to the user (realtime output) if read line by line and show to user then also OK but output should show to user in fast time
not like bash script executed and after execution output will show, i don’t want like that.
the bash script installs library and packages so it may take some time so that i want to show real time output of the bash script to user.

func main() {
        cmd := exec.Command(/* your command */)
        cmd.Stdout = os.Stdout
        cmd.Stderr = os.Stderr
        err := cmd.Run()
        if err != nil {
                log.Fatalf("cmd.Run() failed with %s\n", err)
        }
}

try this one

it’s working thanks, but can’t run curl -Lso- bench.sh | bash

you need to rewrite this command to not use | I suppose
I don’t have any idea, how should it look like.
maybe split it into a two commands?..

You can consider to develop a daemon ,and it can be a ajax for request and response.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.