How to run a python script that is located on another machine

Asked

Viewed 1,021 times

0

I have 2 Raspberry and a windows computer that has an apache server. I want to run a script that is on the server from these 2 Raspberry.

I type in the command line:

sudo python3 192.168.0.8//teste/teste.py 

but the following message:

python3: can’t open file '192.168.0.8/test/test.py': [Errno 2] No such file or Diretory

What am I doing wrong? How to call running a script that is on a server ?

  • On which machine should the script run? On the server or rasp?

  • does not have to do with permission, only configure apache for exec files .py.. as well as configure for java php Django.. can have multiple files inside there only specify localhost:port/Arq.py.. if you are on the same local network using same routing.

2 answers

0

python does not have remote execution functionality. You need to "mount" the remote folder and provide a local path to python:

mkdir /pasta_local
sudo mount -t cifs //192.168.0.8/compartilhamento/ /pasta_local

Then use this folder to access the server:

python3 /pasta_local/teste/teste.py

Another way is, if the script is being provided by apache, you download the script via http, using curl or wget, then just turn around.

curl http://192.168.0.8/teste.py -o teste.py
python3 teste.py

-1

Most likely this is privilege issue, check if the folder in which the files are are allowed to administrator, if you are not with such privileges assign and after that restart the service and try to start the page, If not, make sure that all Python libraries and all resources are installed on the server so that you can find no problems.

First you will edit the sudoers file with the following command:

vim /etc/sudoers or gedit /etc/sudoers

and add the following line to that file:

noun ALL=(root) NOPASSWD: ALL

This way everything you run in apache will be as super user.

  • Hi John, thanks for the quick response. But my server is on a machine running Windows 10 and not Debian. My problem is calling a python script (which is on the windows 10 server) from a Raspberry that is running Debian.

  • that response has no relation to the reported error message. It would be the case if the mistake had to do with the privileges of SUDO, but it is far from being the case.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.