From 98f941b69ac01ce85e8c3a0593b1a405bae28022 Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Sun, 28 Jun 2015 00:23:21 +0500 Subject: [PATCH] Add support for complex commands --- Makefile | 2 +- traffic_modifier.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 18b69e5..693a80f 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ dbench: # Used mainly for debugging, because docker container do not have access to parent machine ports drun: - docker run -v `pwd`:/gopath/src/gor -t -i gor go run $(SOURCE) --input-modifier="./examples/echo_modifier.sh" --input-dummy=0 --output-http="http://localhost:9000" --verbose + docker run -v `pwd`:/gopath/src/gor -t -i gor go run $(SOURCE) --input-modifier="bash ./examples/echo_modifier.sh" --input-dummy=0 --output-http="http://localhost:9000" --verbose dbash: docker run -v `pwd`:/gopath/src/gor -t -i gor /bin/bash \ No newline at end of file diff --git a/traffic_modifier.go b/traffic_modifier.go index 7a34bb9..6a4a5b6 100644 --- a/traffic_modifier.go +++ b/traffic_modifier.go @@ -8,6 +8,7 @@ import ( "log" "os" "os/exec" + "strings" ) type TrafficModifier struct { @@ -26,7 +27,8 @@ func NewTrafficModifier(plugin interface{}, command string) io.Reader { m.command = command m.data = make(chan []byte) - cmd := exec.Command(command) + commands := strings.Split(command, " ") + cmd := exec.Command(commands[0], commands[1:]...) m.Stdout, _ = cmd.StdoutPipe() m.Stdin, _ = cmd.StdinPipe()