exec: executable file not found in $PATH

Mathieu Nls :

I am trying to send the HUP signal to tor in Go.

    command := exec.Command("pidof tor | xargs kill -HUP")
    command.Dir = "/bin"

    if cmdOut, err := command.CombinedOutput(); err != nil {
        log.Panic("There was an error running HUP ", string(cmdOut), err)
        panic(err)
    }

I've tried numerous version of this (with/out args, with/out the Dir, ...) and it always comes back with the same error:

2017/06/27 13:36:31 There was an error running HUP exec: "pidof tor | xargs kill -HUP": executable file not found in $PATH
panic: There was an error running HUP exec: "pidof tor | xargs kill -HUP": executable file not found in $PATH

goroutine 1 [running]:
panic(0x639ac0, 0xc42000d260)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
log.Panic(0xc420049f08, 0x3, 0x3)
        /usr/local/go/src/log/log.go:320 +0xc9
main.main()

Running the command from the console works perfectly:

root@c8927c4a456e:/go/src/github.com/project# pidof tor | xargs kill -HUP
Jun 27 13:40:07.000 [notice] Received reload signal (hup). Reloading config and resetting internal state.
Jun 27 13:40:07.000 [notice] Read configuration file "/etc/tor/torrc".

Here's my $PATH

root@c8927c4a456e:/go/src/github.com/project# echo $PATH
/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

I've done this previously with git command and it was working seamlessly. Am I missing something ?

Adrian :

Per the documentation, the first argument passed to exec.Command is the name of an executable - that's it. It's not interpreted by the shell; it's the name of an executable you want to fork. If you need to pass in arguments, you can pass them in as additional parameters to Command, or you can pass them to the returned object afterward.

In your case, you're using two commands and piping the stdout of one to the stdin of another. You could do this in pure Go (piping the Stdout reader of one to the Stdin writer of the other), or you could rely on the shell to do it. In the latter case, your executable would be sh or bash, and the arguments would be ["-c", "pidof tor | xargs kill -HUP"]. For example:

cmd := exec.Command("bash", "-c", "pidof tor | xargs kill -HUP")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

"exec: \"go\": executable file not found in $PATH"

exec: "sqlboiler": executable file not found in $PATH

godep: exec: "go": executable file not found in $PATH

"exec: "python": executable file not found in $PATH

"sqlplus": executable file not found in $PATH" when running a command with docker exec

docker-exec failed: "cd": executable file not found in $PATH

gcloud app deploy says: exec: "git": executable file not found in $PATH

System error: exec: "deployment": executable file not found in $PATH

exec: "gcc": executable file not found in %PATH% when trying go build

docker local registry "exec: \"htpasswd\": executable file not found in $PATH"

Go moq : running "moq": exec: "moq": executable file not found in $PATH

exec: "com.docker.cli": executable file not found in $PATH

exec: "docker-runc": executable file not found in $PATH: unknown

CloudFoundry staging error exec: "git": executable file not found in $PATH

exec: "php-fpm": executable file not found in $PATH: unknown

Executable file not found in $PATH

starting container process caused "exec: > \"exec\": executable file not found in $PATH": unknown

cgo: exec gcc: exec: "gcc": executable file not found in $PATH Error in Egress operator installation

executable file not found in $PATH Dockerfile

docker: executable file not found in $PATH

executable file not found in $PATH: unknown

Docker Go image: starting container process caused: exec: "app": executable file not found in $PATH: unknown

Getting error executable file not found in $PATH when trying verbose run docker container or when docker exec

Golang docker multi-stage build failing to run: exec: "go": executable file not found in $PATH

Docker Base Simple image : Cannot start container XXX: exec: "cat": executable file not found in $PATH

Error running docker container: starting container process caused "exec: \"python\": executable file not found in $PATH": unknown

Docker container build faild: "exec: \"flask\": executable file not found in $PATH": unknown

How to solve "exec: \"Python\": executable file not found in $PATH": unknown. for simple python script on AWS

Error: exec: \"app.handler\": executable file not found in $PATH", "errorType": "Runtime.InvalidEntrypoint"

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive