I have tried every method on here Execute script on start-up and I still cannot get a .js file to run on start up. The file is very simple:
var noble = require('noble');
var request = require('request');
var http = require('http');
var trim = require('trim');
var LocalmacAddress
require('getmac').getMac(function(err,LocalMacAddress){
if (err) throw err;
console.log(LocalMacAddress);
LocalmacAddress = LocalMacAddress
});
noble.on('stateChange', function(state) {
if (state === 'poweredOn')
noble.startScanning([], true);
else
noble.stopScanning();
});
noble.on('discover', function(peripheral) {
var macAddress = peripheral.uuid;
var rss = peripheral.rssi;
var s = URL HERE
console.log("http://dev.tester.com" + s);
var options = {
host: 'dev.tester.com',
path: s
};
callback = function(response) {
var str = '';
response.on('end', function (chunk) {
str += chunk;
});
response.on('end', function() {
console.log(str);
});
}
http.request(options, callback).end();
});
I have added the to the crontab
,
@reboot sudo /user/local/bin/node /home/pi/Desktop/Scan.js
I have added it to the rc.local
sudo /user/local/bin/node home/pi/Desktop/Scan.js
I have created a script .superscript
and added it to the init.d
.superscript
,./superscript
, or justsuperscript
? I think it should be the latter, looking at the link you provided. – Greenonline Mar 04 '16 at 01:05