cleanup in ftp.sh

master
agp8x 2014-07-22 13:27:55 +02:00
parent d733a7f936
commit a3803ae0f4
2 changed files with 13 additions and 3 deletions

14
ftp.sh
View File

@ -1,11 +1,19 @@
#!/bin/bash #!/bin/bash
cd /home/XXX/temp/python DIR="/home/USER/weather"
SFTPPASS="PASS OR REPLACE WITH KEY"
SFTPUSER="USER@DOMAIN.TLD"
URL="DOMAIN.TLD/PATH/FILE.EXT"
cd $DIR
cp records/humi* ftp/ cp records/humi* ftp/
cp records/ambi* ftp/ cp records/ambi* ftp/
cp records/temp* ftp/ cp records/temp* ftp/
cp records/baro* ftp/ cp records/baro* ftp/
cd ftp cd ftp
sshpass -p 'XXXXXXXXXX' sftp -oBatchMode=no -b - XXXX@YYYYY.ZZZ <<EOF # Using a plain password here is evil, but in my context sadly needed
# better use key-authentication, and switch the commented lines
#sftp -oBatchMode=no -b - $SFTPUSER <<EOF
sshpass -p $SFTPPASS sftp -oBatchMode=no -b - $SFTPUSER <<EOF
mput temp* mput temp*
mput humi* mput humi*
mput ambi* mput ambi*
@ -14,7 +22,7 @@ quit
EOF EOF
rm humi* ambi* temp* baro* rm humi* ambi* temp* baro*
cd .. cd ..
wget YYYYY.ZZZ/temp/new/update.php -O logs/wget_recent -q wget $URL -O logs/wget_recent -q
echo "ftpupload">>logs/ftp.log echo "ftpupload">>logs/ftp.log
date>>logs/ftp.log date>>logs/ftp.log
echo "finished\n\n">>logs/ftp.log echo "finished\n\n">>logs/ftp.log

View File

@ -28,6 +28,8 @@ else:
print("move") print("move")
log.write("moving logs... @"+time.ctime()+"\n") log.write("moving logs... @"+time.ctime()+"\n")
log.flush() log.flush()
if not os.path.exists("arch"):
os.mkdir("arch")
os.system("./move.sh "+preptime()) os.system("./move.sh "+preptime())
check.close() check.close()
check=open(checkfile,'w') check=open(checkfile,'w')