forked from ereedsanchez/GSM-GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
60 lines (47 loc) · 1.28 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//run socket.io
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
//run shell script
var sys = require('sys')
var exec = require('child_process').exec;
app.get('/', function(req, res){
res.sendfile('index.html');
});
io.on('connection', function(socket){
//Mesage
socket.on('Cmessage', function(msg){
io.emit('Cmessage', msg);
console.log('message: ' + msg);
//Mesage shell script
function puts(error, stdout, stderr) {sys.puts(stdout)}
exec("./helloworld.sh", puts);
});
//TRX
socket.on('TurnOnTRX', function(msg){
io.emit('TurnOnTRX', msg);
console.log('TRX: ON');
//TRX shell script
function puts(error, stdout, stderr) {sys.puts(stdout)}
exec("./TurnOnTRX.sh", puts);
});
//BTS
socket.on('TurnOnBTS', function(msg){
io.emit('TurnOnBTS', msg);
console.log("BTS is On");
//BTS shell script
function puts(error, stdout, stderr) {sys.puts(stdout)}
exec("./TurnOnBTS.sh", puts)
});
//BSC
socket.on('TurnOnBSC', function(msg){
io.emit('TurnOnBSC', msg);
console.log('BSC: ON');
//BSC shell script
function puts(error, stdout, stderr) {sys.puts(stdout)}
exec("./TurnOnBSC.sh", puts);
});
});
http.listen(3000, function(){
console.log('listening on *:3000');
});