Webhook: fork/exec: exec format error (question)

Created on 7 Dec 2015  路  22Comments  路  Source: adnanh/webhook

Hi,
I have following settings:

[
  {
    "id": "redeploy-webhook",
    "execute-command": "/home/joseluis/test/hooks/redeploy.sh",
    "command-working-directory": "/home/joseluis/test",
    "response-message": "I got the payload!"
  }
]

I request the hook:

$ curl http://localhost:9000/hooks/redeploy-webhook
I got the payload!

On the terminal I got this error:

$ webhook -hooks hooks.json -verbose 
[webhook] 2015/12/06 16:58:02 version 2.3.6 starting
[webhook] 2015/12/06 16:58:02 setting up os signal watcher
[webhook] 2015/12/06 16:58:02 attempting to load hooks from hooks.json
[webhook] 2015/12/06 16:58:02 loaded 1 hook(s) from file
[webhook] 2015/12/06 16:58:02   > redeploy-webhook
[webhook] 2015/12/06 16:58:02 os signal watcher ready
[webhook] 2015/12/06 16:58:02 starting insecure (http) webhook on :9000
[webhook] 2015/12/06 16:58:07 Started GET /hooks/redeploy-webhook
[webhook] 2015/12/06 16:58:07 redeploy-webhook got matched (1 time(s))
[webhook] 2015/12/06 16:58:07 redeploy-webhook hook triggered successfully
[webhook] 2015/12/06 16:58:07 Completed 200 OK in 265.558碌s
[webhook] 2015/12/06 16:58:07 executing /home/joseluis/test/hooks/redeploy.sh 
(/home/joseluis/test/hooks/redeploy.sh) with arguments 
["/home/joseluis/test/hooks/redeploy.sh"] and environment [] 
using /home/joseluis/test as cwd
[webhook] 2015/12/06 16:58:07 command output: 
[webhook] 2015/12/06 16:58:07 error occurred: 
fork/exec /home/joseluis/test/hooks/redeploy.sh: exec format error
[webhook] 2015/12/06 16:58:07 finished handling redeploy-webhook

My simple echo "Hello" command in redeploy.sh doesn't execute.
What am I doing wrong?

Most helpful comment

Can you add #!/bin/sh on top

All 22 comments

What OS are you running on? Is redeploy.sh executable (do you have exec permissions)?

I have Fedora 22 x64.
Yes my .sh file has exec permisions. chmod +x redeploy.sh
Also, I created a symbolic link of /home/joseluis/.go/bin/webhook to /usr/bin/webhook

What happens when you execute redeploy.sh script manually?

Also, who is the owner of the file? Under which user is webhook running? Can that user access the script?

What happens when you execute redeploy.sh script manually?

Output my echo "Hello" normally.

$ ./redeploy.sh
Hello

Also, who is the owner of the file? Under which user is webhook running? Can that user access the script?

Yes, my user is joseluisthis user was installed Go
and installed webhook to /home/joseluis/.go/bin/webhook
And with this user I created a symbolic link of /home/joseluis/.go/bin/webhook to /usr/bin/webhook
and run webhook webhook -hooks hooks.json -verbose

Or Is it necessary to use root access?

What are the contents of redeploy.sh?

echo "Hello"

Can you add #!/bin/sh on top

Exists some complete example with .sh and hook.json for testing on my OS?

Can you add #!/bin/sh on top

Ok, I will try this...

That's the problem. The first line must be something like this:

#!/bin/sh

That should solve it, can you please confirm so we can close the issue :-)

@adnanh yeah I will confirm soon.. :+1:

Voil脿 now works fine! :smile:

image

Always Shebang on top :smile:

!/bin/sh

Thanks a lot guys.

Glad we could help :-) :+1:

a better error message would be helpful.

... error occurred: fork/exec ... (does your file start with "#!/bin/sh"?)

Wiki page with common errors and possible fixes would be even better :-) Feel free to contribute!

wiki page <<< good error messages :)
if it would be php i would contribute a better error message...

@adnanh I 鉂わ笍 u

:)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adamaze picture adamaze  路  5Comments

Gareth-3aaa picture Gareth-3aaa  路  4Comments

sfxworks picture sfxworks  路  5Comments

wranitzky picture wranitzky  路  6Comments

pascalandy picture pascalandy  路  4Comments