bahamas10 / hue-cli

A command line interface to phillips hue
http://bahamas10.github.com/hue-cli/
221 stars 24 forks source link

cant execute via apache #16

Closed rj-d2 closed 7 years ago

rj-d2 commented 7 years ago

When i try to run a bash script turning my light on and off via apache i get this error:

path.js:7 throw new TypeError('Path must be a string. Received ' + inspect(path)); ^ TypeError: Path must be a string. Received undefined at assertPath (path.js:7:11) at Object.join (path.js:1211:7) at Object. (/usr/lib/node_modules/hue-cli/hue-cli.js:23:23) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:394:7)

it works as expected in when i call it via ssh

here is the script:

#!/bin/bash lights=$(hue lights 1,2,4) if [[ $lights = *off* ]]; then hue lights 1,2,4 on fi if [[ $lights = *on* ]]; then hue lights 1,2,3,4 off fi

would be great if i could execute the script via the webserver,

bahamas10 commented 7 years ago

most likely this line is causing the issue https://github.com/bahamas10/hue-cli/blob/master/hue-cli.js#L22

try setting one of those variables in the bash script before executing the program... like

#!/usr/bin/env bash
export HOMEPATH=/home/user
...

where /home/user is the path that contains a .hue.json config file

On Sun, Dec 11, 2016 at 7:28 AM, scr44tch notifications@github.com wrote:

When i try to run a bash script turning my light on and off via apache i get this error:

path.js:7 throw new TypeError('Path must be a string. Received ' + inspect(path)); ^ TypeError: Path must be a string. Received undefined at assertPath (path.js:7:11) at Object.join (path.js:1211:7) at Object. (/usr/lib/node_modules/hue-cli/hue-cli.js:23:23) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:394:7)

it works as expected in when i call it via ssh

here is the script:

!/bin/bash lights=$(hue lights 1,2,4) if [[ $lights = off ]]; then hue

lights 1,2,4 on fi if [[ $lights = on ]]; then hue lights 1,2,3,4 off fi

would be great if i could execute the script via the webserver,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bahamas10/hue-cli/issues/16, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJl2okunOW5fZpdv57t_d_N6exHU91Hks5rG-x5gaJpZM4LJ6aR .

rj-d2 commented 7 years ago

export HOMEPATH=/home/user --> thx it works now!!