that is most interesting for data-transfer to/from a server outside the LAN = remote server.
However, (much simpler and 'more protected') at a LAN also data transfer between 2 Raspberries of equal stature [not Master & Slave].
For such configuration it seems simplest to just use FTP or RSYNC from one Raspberry to the other.
Have tried with 2 setups, but both 'have a problem', for which suggestions requested for resolution.
First setup is a variation of the FTP-script included in the first message of the other thread mentioned above, obviously with UN+PW set for what is needed now at the LAN.
'Destination' ServerAdress inserted as found in internet-information for insertion of IP-adresses as destination.
Both the 'Source' FTP-server at 192.168.0.186 and the 'Destination' FTP-Server 192.168.0.185 run same version of vsftp-software, and always have.
Obviously the <username> and <password> filled in with actual contents as required to access the 'Destination' FTP-Server.
Code: Select all
#!/usr/bin/python
# -*- coding = utf-8 to enable reading by simple editors -*-
# (c)2020 script compiled by Toulon7559 from various material from forums, version 0.0 for upload of *.rrd to /home/pi/
# --------------------------------------------------
# Line005 = PREPARATION & SETTING
# --------------------------------------------------
# Imports for script-operation
import json
import urllib
# FTP from 192.168.0.186 towards 192.168.0.185
# Raspberry3
print
print ('Start of script Misc1_Upload0186')
# --------------------------------------------------
# Line016 = Function for FTP_UPLOAD to Server
# --------------------------------------------------
# Imports for script-operation
import ftplib
import os
# Definition of Upload_function
def upload(ftp, file):
ext = os.path.splitext(file)[1]
if ext in (".txt", ".htm", ".html"):
ftp.storlines("STOR " + file, open(file))
else:
ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
# --------------------------------------------------
# Line030 = Actual FTP-Login & -Upload
# --------------------------------------------------
ftp = ftplib.FTP("192.168.0.185")
ftp.login("<username>", "<password>")
# set path to destination directory
ftp.cwd('/home/pi/')
# set path to source directory
os.chdir("/home/pi/")
# upload of files
upload(ftp, "piTempest1.rrd")
upload(ftp, "piTempest2.rrd")
# reset path to root
ftp.cwd('/')
print ('End of script Misc1_Upload0186')
CLI=
Code: Select all
sudo python /home/pi/domoticz/scripts/python/Misc1_upload0186.py
Code: Select all
sudo python3 /home/pi/domoticz/scripts/python/Misc1_upload0186.py
Code: Select all
#!/usr/bin/python3
Code: Select all
Start of script Misc1_Upload0186
Traceback (most recent call last):
File "/home/pi/domoticz/scripts/python/Misc1_upload0186.py", line 39, in <module>
upload(ftp, "piTempest1.rrd")
File "/home/pi/domoticz/scripts/python/Misc1_upload0186.py", line 27, in upload
ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
File "/usr/lib/python2.7/ftplib.py", line 479, in storbinary
conn = self.transfercmd(cmd, rest)
File "/usr/lib/python2.7/ftplib.py", line 378, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "/usr/lib/python2.7/ftplib.py", line 341, in ntransfercmd
resp = self.sendcmd(cmd)
File "/usr/lib/python2.7/ftplib.py", line 251, in sendcmd
return self.getresp()
File "/usr/lib/python2.7/ftplib.py", line 226, in getresp
raise error_perm, resp
ftplib.error_perm: 550 Permission denied.
Because most errors reported relate to the ftp-function, what's wrong with this script?
Probably something related to the ServerAdress-setting, because that is the difference in contents, although the errors are pointing to line 027 with function ftp.storebinary (which has not changed, neither the file-types to be transferred)

In this setup also tried ftp://192.168.0.185 as 'Destination'-address, but without success.
Second setup is an RSYNC-scriptline.
This datatransfer is all on LAN, and therefore no ssh needed, and also safe-enough [?] to include username/password in a command-string.
For WLAN may be considered less safe.
CLI=
Code: Select all
export RSYNC_PASSWORD="<password>"; rsync -avz /home/pi/piTempest*.rrd [email protected]:/home/pi
Code: Select all
[email protected]'s password:
Although password included in the above CLI-string, still asking for operator insertion, which hinders automatic execution in a timed cronjob.
Many constructions possible, but what is the SIMPLEST & working automation-construction, including the password in the CLI-string?