user1769686
user1769686

Reputation: 535

javascript,ajax to control shell

I want to write a html page which embed a youtube video and has javascript script. In the script, I will use youtube api and embed a youtube video the youtube api will test whether the video has been downloaded fully

I set up a apache server with mysql and php on the local machine, and put the html page in the apache server

I will use shell script to open firefox with this html page, and use ps -ef|grep "firefox" to get its process id like

firefox http://localhost/test.html

when the youtube api detect that the video has been downloaded fully, I hope it can send a signal to the shell and kill the firefox process so I think it is not possible for javascript to send a signal to shell on the client but since the client and the server are on the same machine, when the youtube api detect that the video has been downloaded fully, ajax can inform the server, like write something the a file or mysql databse on the server.

But I don't know how to link the ajax to sending a signal to shell

does anyone have idea on this? thanks!

Upvotes: 0

Views: 967

Answers (1)

mr.alex
mr.alex

Reputation: 513

To give a complete Answer... Fire an Ajax-Request, when the Video is successfully downloaded, to a PHP-Script that is executing the Shell-Command. Quick and Dirty it could look like this

jQuery

$.get("/runshellcommand.php");

runshellcommand.php

<?php system("kill -QUIT 123456"); ?>

...in this Example "123456" is the PID of Firefox ;-)

Upvotes: 1

Related Questions