I found an easy way to email a web page to myself from the OSX command line using echo, curl, and sendmail.
This is handy if:
- You have a status page online that you want sending to you every day
- You have a business report online that you want sent to you every week/day etc.
- You want a quick backup of an online document
Note, this is simple stuff for anyone who's used Linux for more than a few months I bet!
Here it is on separate lines first...
echo 'Subject: Document Backup' > tmp.txt
echo 'Content-type: text/html' >> tmp.txt
curl http://docs.socena.com/document/test/readme >> tmp.txt
sendmail -v tobin@tobinharris.com < tmp.txt
rm tmp.txt
Or, I can do it in one line like this:
echo 'Subject: Document Backup' > tmp.txt && echo 'Content-type: text/html' >> tmp.txt && curl http://docs.socena.com/document/test/readme >> tmp.txt && sendmail -v tobin@tobinharris.com < tmp.txt && rm tmp.txt
Just copy and paste that into your OSX Terminal (please replace the email address and http:// to your own though!)
You could then create a cron job to have this line executed once a day.
In case your wondering, echo
is just like a print
statement. The >
pipes it to a text file, creating a new file each time. The >>
appends to the file.