[SOLVED]Script not running?

Posted on
Thu Jul 24, 2014 8:32 am
tridens offline
Posts: 35
Joined: Jan 12, 2009

[SOLVED]Script not running?

I'm sure this is simple.

I have an executable script (see below) that works perfectly if I execute it via the command line (OSX's Terminal).

However, I have an Indigo server Action that is supposed to run the script, but it doesn't ...

Any ideas on why the Indigo server would fail to execute a script that I can manually execute just fine?

Code: Select all
#!/usr/bin/env node

var needleClient = require('needle'),
   indigoAuth = { username: 'user', password: 'pass', auth: 'digest' };
   
function setVariable(variable, value, callback){
   needleClient.put('http://127.0.0.1:8176/variables/'+ variable, 'value='+ String(value), indigoAuth, callback);
};

setVariable('alarmArmed', 'true', function(err, resp) { if(err){ console.log(err); } });

Posted on
Thu Jul 24, 2014 1:38 pm
jay (support) offline
Site Admin
User avatar
Posts: 18265
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Script not running?

Likely because node isn't in the path. The IndigoServer and the script host processes don't get the environment that a shell process does when you start it up from a terminal (because those processes run your .profile, .bash_rc, etc). So, basically, this:

Code: Select all
#!/usr/bin/env node


is failing because node isn't found in the standard environment. Instead, point it directly at the node command:

Code: Select all
#!/path/to/node


and I believe it will work.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jul 24, 2014 8:59 pm
tridens offline
Posts: 35
Joined: Jan 12, 2009

Re: Script not running?

Added node to $PATH and changed to:
Code: Select all
 #!/usr/local/bin/node


Works -- thank you!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests