]> Cypherpunks.ru repositories - govpn.git/commitdiff
Simplify external command call
authorSergey Matveev <stargrave@stargrave.org>
Fri, 27 Mar 2015 16:15:23 +0000 (19:15 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 27 Mar 2015 16:15:23 +0000 (19:15 +0300)
Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
common.go

index 545274fb4c3f92c5c5f7da402375280ff872411f..4d8442ea3b679b5d238a287a2e7220b940559723 100644 (file)
--- a/common.go
+++ b/common.go
@@ -19,7 +19,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 package govpn
 
 import (
-       "bytes"
        "encoding/hex"
        "io/ioutil"
        "log"
@@ -45,15 +44,11 @@ func ScriptCall(path, ifaceName string) ([]byte, error) {
        if _, err := os.Stat(path); err != nil && os.IsNotExist(err) {
                return nil, err
        }
-       cmd := exec.Command(path, ifaceName)
-       var out bytes.Buffer
-       cmd.Stdout = &out
-       err := cmd.Run()
-       result := out.Bytes()
+       out, err := exec.Command(path, ifaceName).CombinedOutput()
        if err != nil {
-               log.Println("Script error", path, err, string(result))
+               log.Println("Script error", path, err, string(out))
        }
-       return result, err
+       return out, err
 }
 
 // Read authentication key from the file.