How to read file content and send email on Debian Bullseye

avi.e.gross at gmail.com avi.e.gross at gmail.com
Sat Feb 4 17:10:19 EST 2023


Bart, you may want to narrow down your request to something quite specific.
For example, try to do whatever parts you know how to do and when some part
fails or is missing, ask.

I might have replied to you directly if your email email address did not
look like you want no SPAM, LOL!

The cron stuff is not really relevant and it seems your idea is to read a
part or all of a log file, parse the lines in some way and find a line that
either matches what you need or fail to find it. Either way you want to send
an email out with an appropriate content.

Which part of that do you not know how to do in python? Have you done some
reading or looking?



-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com at python.org> On
Behalf Of ^Bart
Sent: Saturday, February 4, 2023 10:05 AM
To: python-list at python.org
Subject: How to read file content and send email on Debian Bullseye

Hi guys,

On a Debian Bullseye server I have a lftp upload and after it I should send
an email.

I thought to read the lftp log file where I have these lines:

2023-01-30 18:30:02
/home/my_user/local_folder/upload/my_file_30-01-2023_18-30.txt ->
sftp://ftp_user@ftpserver_ip:2201/remote_ftp_folder/my_file_30-01-2023_18-30
.txt
0-1660576 4.92 MiB/s

2023-02-02 18:30:02
/home/my_user/local_folder/upload/my_file_02-02-2023_18-30.txt ->
sftp://ftp_user@ftpserver_ip:2201/remote_ftp_folder/my_file_02-02-2023_18-30
.txt
0-603093 3.39 MiB/s

I'd like to use Python to check, from monday to friday (the lftp script runs
in crontab from monday to friday) when the upload works is finished and I
should send an email.

I could read by Python lftp.log and after it if there's a line with the same
day of the machine I could send an email with ok otherwise the email will
send a message with "no upload".

How could I do by Python?

Regards.
^Bart
--
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list