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

hs.execute returns nil for output #3375

Closed
tonycassara opened this issue Feb 1, 2023 · 3 comments
Closed

hs.execute returns nil for output #3375

tonycassara opened this issue Feb 1, 2023 · 3 comments

Comments

@tonycassara
Copy link

tonycassara commented Feb 1, 2023

Mac OS Ventura 13.2
Hammerspoon 0.9.97

I'm running the script found here: https://github.com/cmer/lg-tv-control-macos/blob/main/lgtv.lua

And it seems on line 16: https://github.com/cmer/lg-tv-control-macos/blob/main/lgtv.lua#L16

The exec_command wrapper for hs.execute is not returning any output. I've tried packing and unpacking the result as well as printing directly from hs.execute to no avail. Does anyone know what's going on? I basically get a blank whitespace (tab?) in my console

@asmagill
Copy link
Member

asmagill commented Feb 2, 2023

Ok, meant to post this here instead of in the other thread:

hs.execute returns 4 results and without knowing what those other result values are, it's hard to say what the problem is... (see http://www.hammerspoon.org/docs/hs.html#execute)

as a debugging measure, you could change line 16 to something like this:

    -- local foreground_app_info = exec_command("getForegroundAppInfo")
    local foreground_app_info, status, typ, rc = exec_command("getForegroundAppInfo")
    print(foreground_app_info, status, typ, rc)

This would show what the other values are. Ideally, the three additional values should be true, "exit", and 0 which would indicate that the command executed and exited properly.

If the number at the end is 127, then it means that the command isn't being found in the path (or the path, if fully specified, is wrong) or that the file doesn't have it's execute bit set. Other numbers would depend... if the program itself uses return codes to indicate problems, you'd need to look at its documentation or man pages; if the program doesn't use return codes, then check the man pages for bash or zsh, depending upon what your default terminal shell is.

@tonycassara
Copy link
Author

@asmagill it was 127!! okay thank you that's a great clue. ill try reinstalling the application bin.

@tonycassara
Copy link
Author

That was it, I installed the app in my root directory, not my user directory. Wow thank you!

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

2 participants