Nannapaneni
Posts: 2
Joined: Wed Mar 07, 2018 11:20 am

How to run a raspbian terminal command using javascript?

Wed Mar 07, 2018 11:33 am

Hello,
If I want to run a command in raspbian terminal using p5.js with the click of a button on the console, what would be the command in js?

User avatar
topguy
Posts: 4997
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: How to run a raspbian terminal command using javascript?

Wed Mar 07, 2018 12:48 pm

Ask the P5.js guys. :-)

In general I would be very surprised if there was such a command in standard Javascript. Code running in a browser should not be able to run system commands because that would totally be a violation of security.

Is p5.js code running on host/server or in the browser ?

Nannapaneni
Posts: 2
Joined: Wed Mar 07, 2018 11:20 am

Re: How to run a raspbian terminal command using javascript?

Wed Mar 07, 2018 1:33 pm

Thank you for your reply.
p5.js code is running in the browser. :o

Heater
Posts: 10274
Joined: Tue Jul 17, 2012 3:02 pm

Re: How to run a raspbian terminal command using javascript?

Wed Mar 07, 2018 3:55 pm

p5.js runs in the browser. As such it cannot run any terminal commands.

You could have the Javascript in the browser communicate with some more Javascript running as a server under node.js. That Javascript can then run shell commands when requested by the browser and return any results back to the browser.

Return to “Other programming languages”