Send shopping list via email - Script file to read in data from local file?

If this topic already exists, I could not find it…

I want to be able send the shopping list via email. I was going down the road of a script since I already have a few of the pieces in place and working. This brings up several questions.

I have SMTP setup and working as a service and can send email.
I have a script set up that can call that service and send a test message (and it works).

I was looking for some way of having a script read the shopping list file but have not had much luck. So first… is there a way to read in a file from a script?

Is there a better way to do what I am trying to do?

I’ve found a few posts that suggest using an external python script to read in the file into a sensor but that appears to have a max length of 255 characters so it won’t hold the data. (I also tried a simple shell script to grep out the name filed of the file but that too is too long, i.e. over 255 characters.)

What is the best way to do what I want to do?

You don’t need a sensor for the message data.

Another way would be to use a python script that fills an attribute from a sensor.
Attributes can be over 255 characters.

Thanks for the suggestion. I ended up just doing it via Python and calling it via a script from an entity button. (I hesitate to do Python scripts because I do most things in Perl. Perl I’m very comfortable with. Python, not so much.)

cat shoppinglistfile|mail -s "Shopping List" [email protected]

If I recall correctly that is, been a while since I have sent email from the commandline :slight_smile: