Javascript + HTML help



Hello glitch community!

I have two questions I am struggling to find an answer too.

My first question Is if I can fetch the logs from 2 different projects, and have them shown on a webpage on one project on my websites admin page.

My second question Is if I can get a sh file running while using a package.json which starts my project on a javascript file, I want to do this so I can use javascript in some circumstances, and still have a sh file enabling apache to be able to use .htaccess files as well!


To answer your first question

It would be possible, but maybe a bit annoying to do.

  1. Constantly get output from the logs.
  2. Store it in a file somewhere
  3. Create a endpoint which returns the logs from the file
  4. Send a request from your admin page to the endpoint then display the logs

To answer your second question

In one of your JS files, use child_process to start a executable/command that is sh


var exec = require('child_process').execFile;

exec("sh", function(err, data)
    // Do stuff with the loaded sh's I/O here.

Hope this helps!


Thank’s for your reply, I am going to try get the second question fixed first, and I have tried doing what you suggested, but it is not working correctly, I may have done something wrong, but I am not sure, and it does not seem to be loading the sh file, and for some reason, it does not seem to want to load my webpages and says it cannot find them anymore.

My project name is catmaniabot, if any staff member could try taking a look!

EDIT: I am loging the errors, and get the following

{ Error: spawn bash ENOENT

7:53 PM

at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)

7:53 PM

at onErrorNT (internal/child_process.js:407:16)

7:53 PM

at process._tickCallback (internal/process/next_tick.js:63:19)

7:53 PM

at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)

7:53 PM

at startup (internal/bootstrap/node.js:283:19)

7:53 PM

at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

7:53 PM

errno: 'ENOENT',

7:53 PM

code: 'ENOENT',

7:53 PM

syscall: 'spawn bash',

7:53 PM

path: 'bash',

7:53 PM

spawnargs: [],

7:53 PM

cmd: 'bash' }


Seems strange… Could you send a snapshot of your code that you used to spawn/load the sh file. Maybe you need to specify the full path of the file. e.g `bash ${__dirname}/`


This is in the javascript file that is loaded.

var exec = require('child_process').execFile;

exec(`bash ${__dirname}/`, function(err, data) {

var express = require('express');
var app = express();
var listener = app.listen(process.env.PORT, function() {
  console.log('Your app is listening on port ' + listener.address().port);

app.get('/', function(request, response) {
  // console.log(wss);
  response.sendFile(__dirname + '/start.html');

This is in the sh file that should be loaded


.mysql/ &
.apache2/ &



Hey @Callum-OKane I think your problem is that you’re using execFile incorrectly. That method takes an executable file and executes it, but instead you’re sending it a command. You may have better luck if you switch to exec.

Also, the contents of the start script in package.json are interpreted as bash commands and you can put any valid command there. For instance you could use something like bash /app/ && node start.js and the commands would work fine.

However, I’m not sure exactly what you’re expecting to accomplish, but I think you’re going to run into problems with this configuration. It looks like you’re trying to start both a Node process running your start.js file and the Apache2 configuration set up in .apache2. Those are both going to try to listen to the same port (and Glitch only opens one) and you’re going to end up with a port conflict.


Hey Cori,
I have not gotten any problem with port conflicting after trying this, but Can you just check that this page does ask you for login before entering the page!


Yep, I get an authentication prompt at that address!