Stumbled Across Something Neat - vutil

Stumbled Across Something Neat - vutil

So, since I'm trying to blog more, let me share some little neat thing I found tonight. It's called vutil. It does a few things, but the neat thing I found is being able to execute system commands via HTTP requests. So, you can then interface with your computer via simple HTTP POST commands remotely. This is very useful for things like home automation or to run simple commands on your computer remotely.

I tried it out on my Windows system in Cygwin with nodejs installed. It's a simple setup: Clone the repo, cd to the vutil dir, and then create a simple config.json file. If you just want to run the command line feature, the config looks like this:

  "activatedModules" : {
    "dbquery" : false,
    "command" : true,
    "csv2json" : false,
    "request" : false,
    "file" : false

Finally, just run npm install while in the directory to get the pre-reqs installed. Run the command like this to run it on any port you want:

PORT=8677 node server.js

Now, all you have to do is POST to http://host/execute/command with a single body parameter named "command" and the value set to the shell command you want to run. I tested a shutdown in Windows like this:

curl -d "command=shutdown /s /t 7200" -X POST localhost:8677/execute/command &

And... it worked!


Since it's running in Cygwin, I can run Cygwin Bash in addition to Windows command-line. Here is me sending "pwd" and the JSON output:

curl -d "command=pwd" -X POST localhost:8677/execute/command

If you read my last few posts - I bet you know what I'm going to say next: ALEXA! (yes, I love her. yes, I would marry her if I could). I mentioned in the Control Practically Anything with Alexa post that the ha-bridge can output HTTP requests. Using vutil, you could have 1 consistent way of interacting with your machines at home (instead of some using SSH, some using EventGhost, some using xyz). For you Google Home users out there, I bet there is a way to configure it so that voice commands translate to HTTP requests. But again, I'm in love with Alexa - so who cares about Google Home? (just kidding - maybe....)

Oh - one other thought: Tasker on Android! Tasker lets you send HTTP requests that can be triggered by tons of events including voice. That would be neat to use with this.

With all this said, you probably don't want to run this anywhere important. It doesn't have any built-in security (it's only restricted by the user context that node is running with), but you could reverse-proxy it with ngnix and turn on authentication + SSL. If you want to expose this outside your home network, that's probably what you should do.