Important: Please read the Qt Code of Conduct -

Executing remote python script

  • I have a python script on my server that I need to execute at certain times (basically whenever I upload a file, we execute this script on said file). How would I go about doing this? The file upload fine, but I have no idea where to start when it comes to executing the python script. Any help would be appreciated, thanks!

  • Some years ago I needed do something like you.
    I can't remember the code, but I used os.stat() every x seconds to check modifications on directories. When stat was modified, ran a special funtion to process changed files (always new files in my case).
    Hope it help.

  • Moderators

    How does this relate to Qt? What OS are you uploading to?

  • Sorry about that, I should have given a bit more detail.

    I'm using Qt to build my client on the front end. I want to execute the Python script on a Ubuntu server from the client after I upload a file (done using QNetworkRequest to POST the data).

  • Moderators

    I would not even try to trigger the script from the client side. Can't you make your server trigger the script in response to the upload?

    If that is not possible then services like upstart (at least the newer versions) can actually monitor directories and trigger scripts whenever they change. Or you can use inotifywait to do the same without upstart.

  • Thanks for the reply Tobias. I'll figure out something server side as oppose to triggering it from the client.

Log in to reply