mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 04:59:25 -07:00
fix: showing the entire error message when a command fails
This commit is contained in:
parent
82dd30c777
commit
dfe64ee4db
2 changed files with 7 additions and 4 deletions
|
@ -41,7 +41,7 @@ func Exec(executable string, args []string) (string, error) {
|
||||||
|
|
||||||
raw, err := exec.Command(path, args...).CombinedOutput()
|
raw, err := exec.Command(path, args...).CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return str.Trim(string(raw)), err
|
||||||
} else {
|
} else {
|
||||||
return str.Trim(string(raw)), nil
|
return str.Trim(string(raw)), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,11 @@ func SetWiFiRegion(region string) error {
|
||||||
|
|
||||||
func ActivateInterface(name string) error {
|
func ActivateInterface(name string) error {
|
||||||
if out, err := core.Exec("ifconfig", []string{name, "up"}); err != nil {
|
if out, err := core.Exec("ifconfig", []string{name, "up"}); err != nil {
|
||||||
return err
|
if out != "" {
|
||||||
|
return fmt.Errorf("%v: %s", err, out)
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
} else if out != "" {
|
} else if out != "" {
|
||||||
return fmt.Errorf("unexpected output while activating interface %s: %s", name, out)
|
return fmt.Errorf("unexpected output while activating interface %s: %s", name, out)
|
||||||
}
|
}
|
||||||
|
@ -289,8 +293,7 @@ func ActivateInterface(name string) error {
|
||||||
func SetInterfaceTxPower(name string, txpower int) error {
|
func SetInterfaceTxPower(name string, txpower int) error {
|
||||||
if core.HasBinary("iw") {
|
if core.HasBinary("iw") {
|
||||||
Debug("SetInterfaceTxPower(%s, %d) iw based", name, txpower)
|
Debug("SetInterfaceTxPower(%s, %d) iw based", name, txpower)
|
||||||
if _, err := core.Exec("iw", []string{"dev", name, "set", "txpower", "fixed", fmt.Sprintf("%d",
|
if _, err := core.Exec("iw", []string{"dev", name, "set", "txpower", "fixed", fmt.Sprintf("%d", txpower)}); err != nil {
|
||||||
txpower)}); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if core.HasBinary("iwconfig") {
|
} else if core.HasBinary("iwconfig") {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue