简体   繁体   中英

How to call a shell script on a click button of java script?

Apologies if I am asking a dummy question but honestly I had searched this a lot but not getting much information so thought to post it here. So I have a UI(running on apache, in html) where have a button, now from that button I want to call a shell script and stop a certain service, could you please guide me how to do it?

I do searched and got to know about node.js but as a DUMMY in server side programming I am not able to do this, will be grateful to you if experts could guide me here.

 if (validate()) { // Preliminary data check to preven unecessary request
  $.ajax(
  '/path/to/your-script', { // the URL where the php script is hosted
     'action': 'update', // variables passed to the server
     'id': '123',
     'value': 'New Value'
  }, function (response) { // server response
   if (typeof(response.success) == 'number' && response.success) {
     }
  }, 'json' // data format
 );
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM