Skip to content
Advertisement

Bash: No such file or directory when running shell comands with node.js spawn on linux

I wrote the following web server in node.js using express and hbs that can run shell files, but I keep getting the following error when I type this url into a web browser

linux username here is replaced with my linux username

JavaScript
JavaScript

Contents of nodejs file:

JavaScript

This is the contents of run.sh:

JavaScript

Advertisement

Answer

Hello, I don’t know why I decided to try to fix this since I know just a little bit about coding (only scripting actually lol) and nothing about nodeJs but I got fun testing your app with the help of my friend google !

First of all, since i dont have your minecraft files (jar etc.), I just writed a little script “test.sh”, that will just echo your command:

JavaScript

second of all after like 2hours of training, modifying, testing by adding/deleting stuff into your app to understand how it works, I finally came back to your original app when i find that it works with this:

JavaScript

here is the browser output (as expected):

JavaScript

here is the console output:

JavaScript

The fact is that when we remove the double quotes from the query it works fine, but when I add back the double quotes like you are trying to do:

JavaScript

here is the browser output (as expected):

JavaScript

but here is the consol output:

JavaScript

So, to conclude, instead of trying to run this on your browser:

JavaScript

try this:

JavaScript

A lot of documentation helped me out to understand the way nodejs works, I loved doing this :p thank you, You made me want to code! bguess.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement