can a raspberry pi get internet from PC via rj45
I have a raspberry pi 1 B and I want it to be connected to pc through RJ45. The problem is I can't access to internet now Is there any solution to get internet shared via RJ45 from my PC ?
See also questions close to this topic
SQlite permissions not enough for execution
I'm developing a small project on raspberry pi based on sqlite3 and python. One of the scripts reads data from sensor and writes them to database (sensor_update.py), the other (cgi script, hello.py) reads last entry in database and prints it on the website. The problem is that the scripts can't write and read from database properly. I set ownership of both database and scripts to www-data and yet when I try to execute database-writing script I get following error:
Traceback (most recent call last): File "sensor_update.py", line 35, in <module> log_temperature(temp) File "sensor_update.py", line 15, in log_temperature curs.execute("INSERT INTO temps values(datetime('now'), (?))", (temp,)) sqlite3.OperationalError: attempt to write a readonly database
I know already that it most probably means that permissions are not right. However ls -l gives output that should indicate that I did everything right:
pi@raspberrypi:/usr/lib/cgi-bin $ ls -l total 20 -rwxr-xr-x 1 www-data www-data 744 Jan 16 20:54 hello.py -rwxr-xr-x 1 www-data www-data 475 Jan 16 20:40 hello.py.backup -rwxr-xr-x 1 www-data www-data 163 Jan 3 22:40 hello.py.save -rwxr-xr-x 1 www-data www-data 197 Jan 3 22:40 hello.py.save.1 -rwxr-xr-x 1 www-data www-data 698 Jan 16 21:11 sensor_update.py pi@raspberrypi:/var/www $ ls -l total 12 drwxr-xr-x 2 root root 4096 Jan 11 08:31 html -rwxr-xr-x 1 www-data www-data 8192 Jan 16 21:11 log.db
Also the cron job doesn't seems to work on the sensor_update.py script. Both programs produce expected output when command is preceded with sudo.
#!/usr/bin/env python import Adafruit_BMP.BMP085 as BMP085 import os import datetime import sqlite3 dbname = '/var/www/log.db' # store the temperature in the database def log_temperature(temp): conn=sqlite3.connect(dbname) curs=conn.cursor() temp = str(temp) curs.execute("INSERT INTO temps values(datetime('now'), (?))", (temp,)) # commit the changes conn.commit() conn.close() def display_data(): conn=sqlite3.connect(dbname) curs=conn.cursor() for row in curs.execute("SELECT * FROM temps"): print str(row)+" "+str(row) conn.close() sensor = BMP085.BMP085() temp=sensor.read_temperature() log_temperature(temp) display_data()
hello.py code (cgi script):
#!/usr/bin/env python import Adafruit_BMP.BMP085 as BMP085 import cgi import cgitb import sqlite3 cgitb.enable() dbname = '/var/www/log.db' def get_data(): conn=sqlite3.connect(dbname) curs=conn.cursor() curs.execute("SELECT * FROM temps ORDER BY timestamp DESC LIMIT 1") result = curs.fetchone() return result if __name__ == "__main__": result=get_data() print result
Piece of apache2 logs:
[Tue Jan 16 21:55:10.812282 2018] [cgi:error] [pid 964] [client ---:52835] Premature end of script headers: hello.py
Python Celery on Raspberry Pi "bash: command not found"
I have a brand new Rasperry Pi that I intend to run a python Flask application along with celery for periodic task and rabbitMq for the message broker. When I attempt to run the following code:
celery -A celeryWorker.celery worker -l INFO --beat
I get the following error:
bach: celery: command not found
I'm copying the code from another Raspberry Pi where the Flask app with celery runs fine. On the new Raspberry Pi I did a pip freeze and amongst the output was this:
I do not have an intent to run this in a virtual environment because this Raspberry Pi will be dedicated to running this application that I'm building.
Also, I'm attempting to run the celery command from a user that I setup but if I try to run the command after running the following code:
sudo su root
I get the same error that the command cannot be found.
I read something about setting up paths for the commands. Could this help? I've looked on the web and everything is very cryptic about modifying bash scripts.
As a side note. I am running Gunicorn (19.7.1) and when I run the following command:
gunicorn -w 1 -b 0.0.0.0:5000 wsgi:app
The flask application works fine. I need to run the celery command in another command line to get the periodic task running. I only note this because with the current user the gunicorn command works fine but the celery command does not.
The OS is Debian Stretch as on January 2018
Raspberry PI: User with "execute only" rights
I would like to hide the files of the webserver in /var/www/html , so I need a user with only access to the home directory. This user should not be able to see or to copy the files in /var/www/html. Furthermore, the webserver still has to execute the files.
How can I do this? The raspberry should boot with this user. Now, the RPI starts Chromium in Kiosk mode after booting - but you could easily end kiosk mode and search for the files via Data-Manager