TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: DENNIS LEE BIEBER
date: 2018-05-18 14:32:00
subject: Re: ftp causing invalid s

On Fri, 18 May 2018 16:53:18 +0100, RobH  declaimed the
following:

>>
>I am getting permission denied when I try to save the python script to
>/mnt/CCTV/PiZero.
>How can I use sudo to do that.
>

 Why are you trying to put the /script/ there?




 Remember -- I don't have a real NAS, so I'm using a variation of
"mount" to redirect part of the file system itself to a mount point.

pi@raspberrypi:~$ ls
Desktop    Downloads  oldconffiles  Public        Templates
Documents  Music      Pictures      python_games  Videos
pi@raspberrypi:~$ ls Public

 Nothing in the "Public" directory... so create a directory tree within
it... This is supposed to be the NAS directory tree (what you would find if
you logged into the NAS itself).

pi@raspberrypi:~$ mkdir Public/myFakeNAS
pi@raspberrypi:~$ mkdir Public/myFakeNAS/aSubDir


pi@raspberrypi:~$ ls /media
pi

 Just some old stuff in /media... Create the "mount point" directory --
this is the location on the RPI where you will mount the NAS -- note that
the path name does not have be a duplicate of the one on the NAS itself

pi@raspberrypi:~$ sudo mkdir /media/FakeNASmnt

 "mount" the "NAS" onto the mount point I created. "--bind" is an option
that allows for source to be a file system rather than a block/network
device (this is all on one line). Also note that I mounted a higher level,
not the bottom-most directory.

pi@raspberrypi:~$ sudo mount --bind /home/pi/Public/myFakeNAS/
/media/FakeNASmnt/

 Show the contents of the /media/FakeNASmnt directory -- note how the
subdirectory I'd created in Public/myFakeNAS is there...

pi@raspberrypi:~$ ls -R /media/FakeNASmnt/
/media/FakeNASmnt/:
aSubDir

/media/FakeNASmnt/aSubDir:

 Create a file in the "NAS" mount point subdirectory

pi@raspberrypi:~$ vim /media/FakeNASmnt/aSubDir/aNewFile.txt
pi@raspberrypi:~$

 Show the file in the mount point

pi@raspberrypi:~$ ls -R /media/FakeNASmnt/
/media/FakeNASmnt/:
aSubDir

/media/FakeNASmnt/aSubDir:
aNewFile.txt

 Copy the file up one level (which is still the faked NAS)

pi@raspberrypi:~$ cp /media/FakeNASmnt/aSubDir/aNewFile.txt
/media/FakeNASmnt/aCopy.dat

 Show results of the copy in the mount point

pi@raspberrypi:~$ ls -R /media/FakeNASmnt/
/media/FakeNASmnt/:
aCopy.dat  aSubDir

/media/FakeNASmnt/aSubDir:
aNewFile.txt
pi@raspberrypi:~$

 Show the contents of the real "NAS"

pi@raspberrypi:~$ ls -R Public/myFakeNAS/
Public/myFakeNAS/:
aCopy.dat  aSubDir

Public/myFakeNAS/aSubDir:
aNewFile.txt
pi@raspberrypi:~$


 Unmount the "NAS"

pi@raspberrypi:~$ sudo umount /media/FakeNASmnt

 The mount point is back to an empty directory...

pi@raspberrypi:~$ ls -R /media/FakeNASmnt/
/media/FakeNASmnt/:

... but the files are still in what would have been the NAS if I had one...

pi@raspberrypi:~$ ls -R Public/myFakeNAS/
Public/myFakeNAS/:
aCopy.dat  aSubDir

Public/myFakeNAS/aSubDir:
aNewFile.txt
pi@raspberrypi:~$


 In effect -- the "ls" and "mkdir" statements with "Public" in the path
are something done while logged into the NAS. (remote machine)

 Statements with "/media" are what one does logged into the R-Pi (local
machine)

 The mount statement is done ON the local machine and "/home/pi" is
filling in for the "IP#" of the remote machine


--
 Wulfraed                 Dennis Lee Bieber         AF6VN
 wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

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™.