开发者

Execute a python script stored on a server/network location on a user's local machine using PHP

开发者 https://www.devze.com 2023-03-02 09:12 出处:网络
I have a webserver running IIS (Machine A) that is running PHP for me. When a user points their browser to a web page that is hosted on the webserver with a PHP script on it, they need to populate a f

I have a webserver running IIS (Machine A) that is running PHP for me. When a user points their browser to a web page that is hosted on the webserver with a PHP script on it, they need to populate a few forms, and then hit a button that will then run the PHP script, which will fire off a python script I've already built. I am using the exec() command in PHP to call my Python script which is stored locally on the webserver (still Machine A). The idea here is that any user on any machine (with python installed on it) can run the script when they navigate to the webpage.

Unfortunately, one of the forms that is needed for the python script to work is a path to an external drive plugged into the user's machine (Machine B).

My question then is: Is there a way that PHP can exec开发者_JS百科ute a python script (stored on Machine A) that is then ran locally (on Machine B) so that when the user has entered in the location of the drive (Win: F:\, Linux: \dev\sda2\, etc ), the python script will know to be looking at the user's local machine (Machine B) rather than the server the script is stored on (Machine A)?

EDIT: Hopefully I have clarified the question above.


The question is not exactly clear, but from my understanding, you're trying to execute code on the local user's machine and you can't do that via Python.

Your best bet is to write JavaScript that will do the job for you (a few browsers only as you're working with local storage due to HTML5), or you can have your user upload the files.


Is there a way that PHP can execute a python script (stored on Machine A) that is then ran locally (on Machine B)

Never. The browsers forbid this kind of security hole.

0

精彩评论

暂无评论...
验证码 换一张
取 消