{"id":24221653,"url":"https://github.com/michdo93/exec-binding-and-exec-action-compendium","last_synced_at":"2026-03-08T05:32:27.706Z","repository":{"id":135030870,"uuid":"529219966","full_name":"Michdo93/Exec-Binding-and-Exec-Action-Compendium","owner":"Michdo93","description":"A compendium for the Exec Binding and Exec Action of openHAB.","archived":false,"fork":false,"pushed_at":"2022-08-31T21:26:30.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T00:45:43.554Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Michdo93.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-26T10:51:30.000Z","updated_at":"2022-08-31T21:22:52.000Z","dependencies_parsed_at":"2023-07-16T00:31:14.164Z","dependency_job_id":null,"html_url":"https://github.com/Michdo93/Exec-Binding-and-Exec-Action-Compendium","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Michdo93/Exec-Binding-and-Exec-Action-Compendium","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michdo93%2FExec-Binding-and-Exec-Action-Compendium","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michdo93%2FExec-Binding-and-Exec-Action-Compendium/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michdo93%2FExec-Binding-and-Exec-Action-Compendium/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michdo93%2FExec-Binding-and-Exec-Action-Compendium/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Michdo93","download_url":"https://codeload.github.com/Michdo93/Exec-Binding-and-Exec-Action-Compendium/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michdo93%2FExec-Binding-and-Exec-Action-Compendium/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30246729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T00:58:18.660Z","status":"online","status_checked_at":"2026-03-08T02:00:06.215Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-14T06:20:17.801Z","updated_at":"2026-03-08T05:32:27.675Z","avatar_url":"https://github.com/Michdo93.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Exec Binding and Exec Action Compendium\nA compendium for the [Exec Binding](https://www.openhab.org/addons/bindings/exec/) and [Exec Action](https://www.openhab.org/docs/configuration/actions.html#exec-actions) of openHAB. This integrates the possibility to execute arbitrary shell commands to openHAB.\n\n## Foreword\n\nThe Exec Binding or Exec Action are actually the most powerful tools you can use in openHAB. You can start, reboot or shutdown remote computers. You can run applications on the local openHAB server or on remote computers. You can run applications in different programming languages. One can run applications in different executable formats. One can interact arbitrarily with the operating system or arbitrarily with command line tools. You can read or write files. Or you can open a file and change or add something to it. You can also interact with databases and other systems. Applications can also be stopped and restarted. System services can be started, stopped or restarted. System monitoring or network monitoring is possible. In short, you can actually communicate with all kinds of computers (mini computers, single board computers, multimedia systems, consoles, robots, etc.).\n\nYou just have to know how.\n\n## Assumption\n\nI assume that openHAB is installed on a Linux operating system.\n\n## Requirements\n\nOf course, you have to be well acquainted with your operating system and its applications.\n\nA Linux operating system is usually more versatile than a Windows operating system. With a few settings, Windows can also be optimized a bit, which ultimately allows us to do a lot more with Windows. This will be explained below. You can use many tools. So well under Windows as under Linux. A few Linux-typical tools can also be installed under Windows. This is also something we want to do. So we bring together some of the possible examples for both operating systems. You don't have to find an alternative tool and explain its operation additionally. Nevertheless, Linux probably offers more operating possibilities from the operating system than Windows. But at the end of the day, why not be able to operate both systems through openHAB?\n\nIn addition to the knowledge of the operating systems, one must of course know that both operating systems run applications differently, that there are different file formats, etc. And finally, you also need some knowledge about the tools and applications you want to use.\n\n## Optimizing a Windows operating System\n\nI assume that you use Minium Windows 10.\n\n### Installing openSSH-Server\n\n### Enable Wake on LAN\n\n### Adding Linux tools to Windows\n\n### Installing PsTools\n\n## Our little helper which\n\nThe `which` command shows in which directory the specified command is found. `which` searches for an executable file only in directories specified in the `PATH` environment variable and returns only the first file (to show all files with the same name, use the -a option).\n\nWhy it makes sense? Because sometimes the same application exists multiple times. Accordingly, it makes sense that you angbit the exact path.\n\n```\nwhich python\n/usr/bin/python\n```\n\nor\n\n```\nwhich python3\n/usr/bin/python3\n```\n\nwould not make any difference. You can also run `python` or `python3`. But Python is a very good example that there are virtual Python environments ([virtualenv](https://virtualenv.pypa.io/en/latest/)). To make it simple: I can install packages in a `virtualv` independently from the ones the complete system uses for Python. If I would use `/usr/bin/python3` instead of `/path/to/virtual_environment/bin/python3`, the system does not know these installed packages. So the dependencies cannot be resolved! Thus, the program cannot be executed without errors.\n\nTo stay with the Python example, you can change to the virtual environment directory, activate that virtual environment, and use `which` to check which Python is started.\n\n```\ncd /path/to/virtual_environment/\nsource bin/activate\nwhich python3\n/path/to/virtual_environment/bin/python3\n```\n\nSo at least you can use `/path/to/virtual_environment/bin/python3 \u003cfile\u003e.py` to run your Python code without any errors!\n\nPython, of course, is not the only good example of why it makes sense to ultimately specify the full path to the executed application:\n\n* Environment variables can be set up locally for one user or globally for all users.\n* An application was simply not added to the `PATH` variable. With which you will not find it then, but you can use which to check if this application has been added to the `PATH` variable. Accordingly, you can still add this variable to the `PATH` variable or you can directly use the full path to the application for openHAB.\n* Using the example of system services, you can see that this application also executes with the full path specification. This is due, for example, to the fact that the environment variables may not be loaded.\n* Using `SSH` as an example, one also experiences time and again that applications cannot be executed because they are often only specified in the local `PATH` variable.\n* On Linux, the `executables` are often moved to standard directories such as `/usr/bin/`, `/sbin/`, `/usr/local/bin/` or referenced with `symbolic links` when they are installed. In Windows there is usually a directory for installed programs for `x86` and for `64-bit`, but the `exe` files are usually located there in subfolders from the manufacturer and the name of the program. Thus the PATH variable with Windows usually does not know the `Exe` file.\n* A program was installed manually and is therefore not located in a directory used by the `PATH` variable.\n\nTo reduce possible sources of error, we use `which` to figure out how to run an application as independently of the environment variables as possible.\n\n## Environment variables\n\n### PATH\n\n#### Linux\n\n#### Windows\n\n### PYTHONPATH\n\n## The principle of whitelist and blacklist\n\nA `whitelist` or `blacklist` is a positive or negative list that can be used to protect systems in the IT environment. A `blacklist` prohibits the execution of something, while the `whitelist` allows it.\n\nIn openHAB the `exec.whitelist` is used for the `Exec Binding` and for the `Exec Action`. Therefore you have to explicitly allow openHAB to execute this command.\n\n### Editing the exec.whitelist\n\nIf your openHAB configuration folder is in `/etc/openhab` you can find the `exec.whitelist` in `/etc/openhab/misc`. You can change it with `sudo nano /etc/openhab/misc/exec.whitelist`. If this folder or file does not exist you have to create it:\n\n```\nsudo -u openhab mkdir /etc/openhab/misc\nsudo -u openhab touch /etc/openhab/misc/exec.whitelist\n```\n\nBefore you add a `\u003ccommand\u003e`, you can still test this command:\n\n```\nsudo -u openhab \u003ccommand\u003e\n```\n\nWith `sudo -u openhab` you make sure that the `openhab` user, which should have been created during the installation of openHAB, can execute this command. If it's not the case, openHAB can not run this command.\n\nAt least there is one important point. Each command needs a new line in the `exec.whitelist`. This means as example:\n\n```\n\u003ccommand\u003e\n\u003ccommand2\u003e\n\u003ccommand3\u003e\n```\n\nOf course you can add comments with `#`:\n\n```\n\u003ccommand\u003e # needed to shutdown the pc\n\u003ccommand2\u003e # playing Minecraft\n\u003ccommand3\u003e # another useless comment\n```\n\nWhat do I mean with `\u003ccommand\u003e`? Well with `\u003ccommand\u003e` I mean the whole line you will enter in your command line interface before pressing enter. So your `\u003ccommand\u003e` can be very long like as example: `/usr/bin/sshpass -p \u003cpassword\u003e /usr/bin/ssh \u003cuser\u003e@\u003cip\u003e \"echo Hello World!\"`.\n\nAnother important point is that every time I use `\u003c` and `\u003e` you have to replace it with your parameter. This could be as example the ip address, username or password from your remote computer by replacing `\u003cip\u003e`, `\u003cuser\u003e` and `\u003cpassword\u003e`. So every time I use `\u003c` and `\u003e` I will use it as placeholder.\n\n## What is a command line and how to run commands on a command line?\n\n### Run commands locally\n\n### Run commands remotely\n\n### Shell? Bash? Terminal? Command Line? - An introduction \n\n### Batch and Bash commands equivalents\n\n## What about scripts?\n\n### Bash scripts\n\n### Shell scripts\n\n### Batch scripts\n\n## Wake on LAN, Reboot and Shutdown\n\n## Runnning System Services\n\n### Split down a system service\n\n## Running different programming languages\n\n### Running Python\n\n### Running Java\n\n### Running C\n\n### Running C++\n\n### Running C#\n\n### Running JavaScript\n\n### Running PHP\n\n## Running applications\n\n### Running executables\n\n### Running Steam\n\n### Running Unity\n\n### Running Chrome\n\n### Running Firefox\n\n### Running VLC\n\n## Running ROS (Robot Operating System)\n\n## Runing system tools\n\n## Running network tools\n\n## File interactions\n\n### Moving files and folders\n\n### Creating files and folders\n\n### Renaming files and folders\n\n### Deleting files and folders\n\n### Change permissions of files and folders\n\n### Change owners\n\n### Reading a file\n\n### Writing a file\n\n### Append content to a file\n\n## Interacting with databases\n\n## Creating and Restoring Backups\n\n### Archive files\n\n### Image files\n\n### Git\n\n## Interacting with openHAB via Command Line\n\n### Using Curl\n\n### Using the Karaf Console\n\n#### Karaf Commands\n\n#### Rules\n\n#### Things\n\n#### Items\n\n## Controlling Virtual Machines\n\n### VMware Workstation Player\n\n### VMware Remote Console\n\n### Oracle VirtualBox\n\n## Controlling Docker\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichdo93%2Fexec-binding-and-exec-action-compendium","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichdo93%2Fexec-binding-and-exec-action-compendium","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichdo93%2Fexec-binding-and-exec-action-compendium/lists"}