Run Bash Script with Node from client request

前端 未结 2 1811
青春惊慌失措
青春惊慌失措 2021-02-02 02:22

I need to make a server-side script run when a user from the browser clicks a button...

I\'ve been researching for a while, and can\'t figure it out.

What we hav

2条回答
  •  被撕碎了的回忆
    2021-02-02 02:37

    You are on the right way with your first approach, the child_process.spawn variant. Ofcourse you can't put this in the HTML page, as it is then executed in the browser, not in the server, but you can easily create a request in the browser (AJAX or page load, depending on what you need), that triggers running this script in the server.

提交回复
热议问题