Last active
February 14, 2025 09:23
-
-
Save coderofsalvation/5dca9fcc74c0044d1232cba164a0f06d to your computer and use it in GitHub Desktop.
shellscript which forwards filesystem inotify events to webpage [inotify-tools + websocat]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo ' | |
<h1>/tmp watcher</h1> | |
<pre> | |
try: $ touch /tmp/FOO | |
$ chmod +x /tmp/FOO | |
$ xattr -s foo -V bar /tmp/FOO | |
</pre> | |
<pre id="log"> | |
output | |
====== | |
</pre> | |
<script> | |
var ws = new WebSocket("ws://127.0.0.1:'$PORT'/"); | |
ws.onmessage = function(event) { | |
document.querySelector("#log").innerHTML += "\n"+event.data; | |
}; | |
</script> | |
' > /tmp/index.html | |
echo "point your browser to: https://127.0.0.1:9090" | |
inotifywait -m /tmp | websocat -E -s 9090 -F /:text/html:/tmp/index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment