Last active
April 18, 2019 03:50
-
-
Save shin1x1/1e18182fa0c48393f98ac6de1a90a283 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"os/exec" | |
"sync" | |
"time" | |
) | |
func main() { | |
if len(os.Args) == 1 { | |
log.Fatalf("Usage: %s command", os.Args[0]) | |
} | |
command := os.Args[1] | |
var args []string | |
if len(os.Args) > 2 { | |
args = os.Args[2:] | |
} | |
var wg sync.WaitGroup | |
for { | |
wg.Add(1) | |
go func(command string, args []string) { | |
defer wg.Done() | |
fmt.Println(command, args) | |
cmd := exec.Command(command, args...) | |
cmd.Stdout = os.Stdout | |
cmd.Stderr = os.Stderr | |
if err := cmd.Run(); err != nil { | |
fmt.Println(err) | |
} | |
time.Sleep(10 * time.Second) | |
}(command, args) | |
wg.Wait() | |
} | |
} |
Author
shin1x1
commented
Apr 18, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment