Task 1
Description
It shall be possible to start and stop programs on the Raspberry PI from a remote PC. A program shall be implemented with these features:
- start a program on the Raspberry PI
- stop a program already running on the Raspberry PI
- upload a configuration file to the RPI
- the configuration file is used by the program that is started on the RPI
The program resides on the PC. It connects to the RPI via opening a SSH session:
- It checks whether the program on the RPI is already running. Depending on a command parameter a specific program is either kept running or it is stopped.
- A configuration file (if required by the program which shall be started) is uploaded via SFTP to the RPI
- Finally (depending of another parameter) the program on the RPI is started
- the SSH session will be closed without affecting a program which had been started
Depending on command parameters it is therefore possible:
- to start a program
- to abort running programs (and then start a program)
- only to abort running programs
Implementation
The program startStopRemoteProgram.py
is started on the PC like this:
python startStopRemoteProgram.py sshCredentialsJS configJS kill_running_processes start_program
Command parameters
parameter | description |
sshCredentialsJS | json file with credentials requred to login via SSH / SFTP |
configJS | json file with configuration data (identifies which program shall be started / stopped; path to configuration file of program, … |
kill_running_processes | the parameter is string parameter with one of the following values: y, Y, n, N [y, Y] -> already running program will be stopped |
start_program | the parameter is string parameter with one of the following values: y, Y, n, N [y, Y] -> program will be started |
Use cases
Some more frequent use cases of program startStopRemoteProgram.py
are described on GitHub.
Summary
Program startStopRemoteProgram.py
is a helper program to start a program on the Raspberry PI remotely. It uses Python library paramiko
to implement the SSH / SFTP functionality.
Resources