TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ROBH
from: VINCENT COEN
date: 2020-11-14 13:53:00
subject: Pript rut rut run in Pi d

Hello RobH!

Friday November 13 2020 09:14, you wrote to me:

 > On 10/11/2020 10:42, Vincent Coen wrote:
 >> Hello RobH!
 >>
 >> Tuesday November 10 2020 20:08, you wrote to me:
 >>
 >> Do a ssh into your Pi.
 >> Then do
 >> pwd
 >> ls -la
 >>
 >> Now do
 >> sudo -s
 >> pwd
 >> ls -la
 >>
 >>
 >> and report what you get
 >>
 >> Vince
 >>
 >>
 >>   > On 10/11/2020 06:05, Vincent Coen wrote:
 >>   >> Hello RobH!
 >>   >>
 >>   >> Tuesday November 10 2020 17:40, you wrote to All:
 >>   >>
 >>   >>   > I have a python script to run some leds, and I'm having a
 >>   >> problem with
 >>   >>   > it! When I ssh into my pi zero, then sudo python3 python
 >>   >> script.py, it
 >>   >>   > doesn't run, no leds are lit.
 >>   >>   > But if I open a terminal in the pi desktop and run the same
 >>   >> command
 >>   >>   > line, it works and the leds light up.
 >>   >>
 >>   >>   > Anyone know why this happens.
 >>   >>
 >>   >> Who owns the script.py and where is it ?
 >>   >>
 >>   >>
 >>   >> Remember sudo takes root priv. and the directory so try :
 >>   >>
 >>   >> sudo python3 /home/pi/script.py   or whater the user name is
 >> along
 >>   >> with the correct python run command is.
 >>   >>
 >>   >>
 >>   >> Vincent
 >>   >>
 >>
 >>   > I ssh'd into my pi zero, then I created the script with : sudo
 >> nano
 >>   > script.py then copied some other python script into the new
 >> script.py.
 >>   > I then ran sudo python3 script.py from within the directory the
 >> said
 >>   > script is in, which is the Downloads directory.
 >>   > Nothing happens, no errors, no leds lit.
 >>
 >>   > If I open a terminal window on the pi desktop and run the exact
 >> same
 >>   > sudo python3 script.py, it runs and the leds light up
 >>
 >>
 >>
 >> Vincent
 >>

 > Apologies for late reply but here are the results of what you asked:

 > pi@raspberrypi:~ $ pwd
 > /home/pi
 > pi@raspberrypi:~ $ ls -la
 > total 92
 > drwxrwxrwx 15 pi   pi   4096 Nov 11 12:32 .
 > drwxr-xr-x  3 root root 4096 Aug 20 11:31 ..
 > -rw--w--w-  1 pi   pi    671 Nov 10 20:11 .bash_history
 > -rw-rw-rw-  1 pi   pi    220 Aug 20 11:31 .bash_logout
 > -rw-rw-rw-  1 pi   pi   3523 Aug 20 11:31 .bashrc
 > -rw-r--r--  1 root root  364 Nov  8 17:22 blinkatest.py
 > drwxrwxrwx  2 pi   pi   4096 Aug 20 11:40 Bookshelf
 > drwxrwxrwx  6 pi   pi   4096 Nov  8 17:20 .cache
 > drwx-w--w- 12 pi   pi   4096 Nov 10 17:10 .config
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Desktop
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Documents
 > drwxrwxrwx  6 pi   pi   4096 Nov 10 20:40 Downloads
 > drwx-w--w-  3 pi   pi   4096 Aug 20 12:09 .gnupg
 > drwxrwxrwx  5 pi   pi   4096 Nov  8 17:20 .local
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Music
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Pictures
 > -rw-rw-rw-  1 pi   pi    807 Aug 20 11:31 .profile
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Public
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Templates
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Videos
 > -rw--w--w-  1 pi   pi     56 Nov 11 12:32 .Xauthority
 > -rw-------  1 pi   pi   2493 Nov 11 12:32 .xsession-errors
 > -rw-------  1 pi   pi   2493 Nov 11 09:17 .xsession-errors.old
 > pi@raspberrypi:~ $ sudo -s
 > root@raspberrypi:/home/pi# pwd
 > /home/pi
 > root@raspberrypi:/home/pi# ls -la
 > total 92
 > drwxrwxrwx 15 pi   pi   4096 Nov 11 12:32 .
 > drwxr-xr-x  3 root root 4096 Aug 20 11:31 ..
 > -rw--w--w-  1 pi   pi    671 Nov 10 20:11 .bash_history
 > -rw-rw-rw-  1 pi   pi    220 Aug 20 11:31 .bash_logout
 > -rw-rw-rw-  1 pi   pi   3523 Aug 20 11:31 .bashrc
 > -rw-r--r--  1 root root  364 Nov  8 17:22 blinkatest.py
 > drwxrwxrwx  2 pi   pi   4096 Aug 20 11:40 Bookshelf
 > drwxrwxrwx  6 pi   pi   4096 Nov  8 17:20 .cache
 > drwx-w--w- 12 pi   pi   4096 Nov 10 17:10 .config
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Desktop
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Documents
 > drwxrwxrwx  6 pi   pi   4096 Nov 10 20:40 Downloads
 > drwx-w--w-  3 pi   pi   4096 Aug 20 12:09 .gnupg
 > drwxrwxrwx  5 pi   pi   4096 Nov  8 17:20 .local
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Music
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Pictures
 > -rw-rw-rw-  1 pi   pi    807 Aug 20 11:31 .profile
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Public
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Templates
 > drwxrwxrwx  2 pi   pi   4096 Nov  8 16:40 Videos
 > -rw--w--w-  1 pi   pi     56 Nov 11 12:32 .Xauthority
 > -rw-------  1 pi   pi   2493 Nov 11 12:32 .xsession-errors
 > -rw-------  1 pi   pi   2493 Nov 11 09:17 .xsession-errors.old
 > root@raspberrypi:/home/pi#


 > Thanks


Well from the above it appears you auto log in to the default user (pi) which
is also the super user  However the file blinkatest.py was created by root not
user pi.

So try this log in as pi then do :

chown pi: blinkatest.py


Now try running the python script.


Bye the bye on my systems I have myself as a (normal) user i.e., vince without
root privledges etc and always log in as me.

If I have to do any root admin processes I do sudo (or su - )  as needed and
then exit admin before continuing any thing else.


I recommend you do this even if the Pi will only be used standalone as it is
good practice for when you do have a system that talks to the outside world.

Also ensure that your router is correctly set up for security ie., the 
firewall
settings also to help with this set up a FIXED ip address for your computers
that connrect to the router and don't use DHCP so start with the first
available IP number eg, 192.168.1.1  (yours might be 192.168.0.1).

In any event for the first system use .1 and the next .2 and keep a note of
what IP address is used in what system.

Don't bother for portables i.e., mobiles but for at home one's you might do 
so.


All the above help you connect system to system as you know their addresses
where with the default addressing you have to hunt for it and if it gets
turned off then on again will have a different IP address every time.

Vincent

--- Mageia Linux v7.1 X64/Mbse v1.0.7.17/GoldED+/LNX 1.1.5-b20180707
* Origin: Air Applewood, The Linux Gateway to the UK & Eire (2:250/1)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.