Bunyod Shams
Bunyod Shams

Reputation: 33

How to run python script remotely on raspberry pi from another machine?

My first piece of code is inside of my pc which detects characters at a part of the screen. Once it detects a certain sequence then it needs to send a signal to the raspberry pi which controls LEDs. I know that I can use SSH to run things remotely on a raspberry pi. But how do I automate it?

For example if I have the following code inside of my main pc

if numbs == [1,1,2]:
    #enter this code into the ssh to run leds.py on the raspberry

The pi is running standard Linux based raspbian.

If you have any other suggestions on better ways of doing this I'm open to ideas.

Upvotes: 0

Views: 939

Answers (1)

Someanonimcoder
Someanonimcoder

Reputation: 11

You can automate anything on linux(raspbian in particular) in many ways.

First option is to use cron command. I'd say it is a simplest option, and pretty powerful: you can run your code once a minute, once a day, on each fridady 13th, etc.

Another option is writing systemd service for your task. Its pretty hard way, but even more powerful then the first one.

Another option special for python scripts is python package supervisor, which is kinda like prevoius solutions.

Upvotes: 1

Related Questions