Home > Net >  How can I invoke a .py script remotely?
How can I invoke a .py script remotely?

Time:11-26

I have a script on my local machine that I would like to run remotely. This script requires a lot of GPU power so I can’t run it from my laptop or phone which I would like to do. If there’s any way I could connect to my local machines powershell or command prompt please let me know.

CodePudding user response:

Use ssh, exemple:

ssh [email protected] python -

CodePudding user response:

There are many services that offer free use of GPUs (and the ability to upgrade to paid services).

Some of the big providers are:

  • enter image description here

    Feel free to read more here.

    CodePudding user response:

    I don't know about running PowerShell commands on mobile...

    However, as long as you have your computer set up for remote access (WARNING: dangerous if you are exposing it over the internet and not simply local) (see PowerShell Remote and WSMan), then the following would be simple:

    $cred = Get-Credential -Message "local machine credentials"
    Invoke-Command -Credential $cred -ComputerName <your local IP> -ScriptBlock {
        C:\path\to\python.exe C:\path\to\script.py
    }
    

    Something that would be safer would be to expose it through a REST API. This approach would be safer from a security standpoint (although there may still be either attacks or other people utilizing your local machine if exposed publicly). You could then either design it so that any browser can render your output with HTML (see Flask if you want to use Python on your local machine), or you could return json and have a script on your mobile that parses and renders it or whatever you wish.

  • Related