Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fork/exec: exec format error (question) #60

Closed
joseluisq opened this issue Dec 6, 2015 · 23 comments
Closed

fork/exec: exec format error (question) #60

joseluisq opened this issue Dec 6, 2015 · 23 comments

Comments

@joseluisq
Copy link

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?

@moorereason
Copy link
Collaborator

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

@joseluisq
Copy link
Author

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

@adnanh
Copy link
Owner

adnanh commented Dec 7, 2015

What happens when you execute redeploy.sh script manually?

@adnanh
Copy link
Owner

adnanh commented Dec 7, 2015

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

@joseluisq
Copy link
Author

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?

@moorereason
Copy link
Collaborator

What are the contents of redeploy.sh?

@joseluisq
Copy link
Author

echo "Hello"

@adnanh
Copy link
Owner

adnanh commented Dec 7, 2015

Can you add #!/bin/sh on top

@joseluisq
Copy link
Author

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

@joseluisq
Copy link
Author

Can you add #!/bin/sh on top

Ok, I will try this...

@moorereason
Copy link
Collaborator

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

#!/bin/sh

@adnanh
Copy link
Owner

adnanh commented Dec 7, 2015

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

@joseluisq
Copy link
Author

@adnanh yeah I will confirm soon.. 👍

@joseluisq
Copy link
Author

Voilà now works fine! 😄

image

Always Shebang on top 😄

#!/bin/sh

Thanks a lot guys.

@adnanh
Copy link
Owner

adnanh commented Dec 7, 2015

Glad we could help :-) 👍

@adnanh adnanh closed this as completed Dec 7, 2015
@c33s
Copy link

c33s commented Jan 12, 2017

a better error message would be helpful.

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

@adnanh
Copy link
Owner

adnanh commented Jan 12, 2017

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

@c33s
Copy link

c33s commented Jan 12, 2017

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

@joseluisq
Copy link
Author

Done !
https://github.com/adnanh/webhook/wiki/Home/_compare/aaa832b5ba58f0904fdcba183d1fc8184caafd00?diff=unified

@joseluisq
Copy link
Author

And the history changes: https://github.com/adnanh/webhook/wiki/Home/_history

@sourcec0de
Copy link

@adnanh I ❤️ u

@adnanh
Copy link
Owner

adnanh commented Mar 9, 2017

:)

464bb26bac556e85b6fd6b524347b103 added a commit to 464bb26bac556e85b6fd6b524347b103/webhook that referenced this issue Jun 4, 2018
A change was made in response to adnanh#60 (fork/exec: exec format error) on the wiki that would be useful to also propagate to the readme.
@nahayoarthur
Copy link

Can you add #!/bin/sh on top

it solved my issue, thanks a lot 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants