lilzz
Posts: 411
Joined: Sat Nov 30, 2013 5:27 pm

executing a python file and bash script in javascript.

Fri May 30, 2014 6:58 am

In php, you can do
exec('sudo python test.py');

I am not sure in how to do that in javascript

Also how to give out bash script command in javascript.

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: executing a python file and bash script in javascript.

Fri May 30, 2014 7:49 am

You can't, for security reasons.
PHP is running on the server side, jvascript (usually) on the clients side, If javascript could access files or even execute programs, it would open the door to everyone modify your system.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: executing a python file and bash script in javascript.

Fri May 30, 2014 7:51 am

That is not possible in browsers because it would be a massive security risk. Under node.js , it is possible , though :

http://nodejs.org/api/child_process.html

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Return to “General discussion”