Running commands in init script


#1

Sorry I can’t figure this out.

I would like to run the following two commands with the workspace starts up:

mysql-ctl start
rvm install ruby-2.3.1

I tried this:

services.proc.execFile(
  "mysql-ctl", 
  {args: ['start'], cwd: "/home/ubuntu/workspace"}, 
  function(err, stdout, stderr) {
    if (err) return console.error(err);
    console.log(stderr, stdout);
  });

and many variations


#2

try using bash

services.proc.execFile("bash",   {
    args: ["-c", "mysql-ctl start"], 
    cwd: "/home/ubuntu/workspace"
},  function(err, stdout, stderr) {
    if (err) return console.error(err);
    console.log(stderr, stdout);
});

NOTE: it is probably a good, idea to add an if statement to check that it is one of your workspaces, otherwise you can inadvertently run commands on shared workspaces too/


#3

I entered MySQL-start and received bash: mysql-ctl: command not found ?? Any help please


#4

I’m getting the same thing…command not found when entering MySQL-start