How programmer gets his wife happy

2 min read

Don’t wanna get your wife angry just because of let her wait so long for a dinner? This program is for you. It’s a guide to build the simple application that automatically sends SMS to your wife at a specific time if you need to stay longer at the office.

zen8labs programmer

Get Twilio account

Register an account at: https://www.twilio.com, the service lets you send the SMS via REST API. During trial period, you could get 10$ — enough free messages; then you get charged with low fare later (~0.01–0.05$ for each SMS).

Setup Twilio

Now replace this command with your information above, replace + in the phone number with %2B.

curl -s -X POST “https://api.twilio.com/2010-04-01/Accounts/{ASID}/SMS/Messages.xml" -d From=”{SENDER}” -d To=”{RECEIVER}” -d Body=”{MESSAGE}” -u {KSID}:{KSECRET}
curl -s -X POST “https://api.twilio.com/2010-04-01/Accounts/{ASID}/SMS/Messages.xml" -d From=”{SENDER}” -d To=”{RECEIVER}” -d Body=”{MESSAGE}” -u {KSID}:{KSECRET}

Then run.

curl -s -X POST “https://api.twilio.com/2010-04-01/Accounts/ACa225474ed0119821diekxu29dvcc30bfe/SMS/Messages.xml" -d From=”%2B1914–595–1437" -d To=”%2B988999888" -d Body=”I'm busy today and might come home late. Love you my dear” -u SKe893oxkdks5c9bc4fea37b1de9f1de396:sJRZaW8fn2M0kalxielxmq9ZM15Z1czW3R
curl -s -X POST “https://api.twilio.com/2010-04-01/Accounts/ACa225474ed0119821diekxu29dvcc30bfe/SMS/Messages.xml" -d From=”%2B1914–595–1437" -d To=”%2B988999888" -d Body=”I'm busy today and might come home late. Love you my dear” -u SKe893oxkdks5c9bc4fea37b1de9f1de396:sJRZaW8fn2M0kalxielxmq9ZM15Z1czW3R

Got it? We are almost done.

Setup a cronjob

You can send SMS to your wife by only 1 command; now get it automated.

1. Create a file sweet_sms_to_darling.sh, put the command above.

#!/bin/bash # Script to send an SMS alert via Twilio. curl -s -X POST “https://api.twilio.com/2010-04-01/Accounts/ACa225474ed0119821diekxu29dvcc30bfe/SMS/Messages.xml" -d From=”%2B1914–595–1437" -d To=”%2B988999888" -d Body=”I'm busy today and might come home late. Love you my dear” -u SKe893oxkdks5c9bc4fea37b1de9f1de396:sJRZaW8fn2M0kalxielxmq9ZM15Z1czW3R

# Script to send an SMS alert via Twilio.

curl -s -X POST “https://api.twilio.com/2010-04-01/Accounts/ACa225474ed0119821diekxu29dvcc30bfe/SMS/Messages.xml" -d From=”%2B1914–595–1437" -d To=”%2B988999888" -d Body=”I'm busy today and might come home late. Love you my dear” -u SKe893oxkdks5c9bc4fea37b1de9f1de396:sJRZaW8fn2M0kalxielxmq9ZM15Z1czW3R

2. Get it executable, and run at 18:30 every day.

MacBook-Pro:twilio tom$ chmod 775 sweet_sms_to_darling.sh MacBook-Pro:twilio tom$ vi /etc/crontab

MacBook-Pro:twilio tom$ chmod 775 sweet_sms_to_darling.sh

MacBook-Pro:twilio tom$ vi /etc/crontab

Add this line, correct your file path, 18, 30 is the hour and minute triggers this bash script.

30 18 * * * ~/Desktop/twilio/sweet_sms_to_darling.sh

30 18 * * * ~/Desktop/twilio/sweet_sms_to_darling.sh

3. Save this file and add to cronjob. That’s all.

MacBook-Pro:twilio tom$ crontab /etc/crontab

MacBook-Pro:twilio tom$ crontab /etc/crontab

OK, now when your computer is up on 18:30, it automatically send the SMS to your wife.

Don’t worry about she get angry. Now work.

Please don’t put this job on server — it’s always up ?

It’s general idea of building the application, you could do it in others platform like Windows with BAT file and scheduled task. Another simpler and specific version for Mac is coming soon ? Part 2

Related posts

Knowing the correct scan is important to accessing the right data and improving queries. In our latest blog we look at different scan types used in PostgreSQL and what they do
8 min read
MySQL is a popular open-source relational database management system. It has many variations and nuances to it, our latest blog breaks down three areas for you to understand how to use them to your benefit.
5 min read
Nextjs has been a beneficial framework for developers. In this current blog we look at two sides; client components versus server components. What are they and why they should matter to you? Find out in this new blog.
4 min read