Post# 1607796622

13-Dec-2020 12:10 am


#howto Send SMS from your Linux machine console command.

Why? That way you can automatically send mass SMS or create an interactive billing server where people SMS you "bill" and you SMS back -- "Your due bill is xx,xxx/=." or "Your payment of x,xxx/= has been received. Current balance xx,xxx/=". Or maybe create an SMS service like how the cell phone operators manages.

//
"Ok, enough talk, show me how?"

Wrong way : install some crapware from some little known company from app store which will fill your phone with ads and what not.

The right way.

1. Install f-droid.

search net to figure out how.

2. Install "termux" from f-droid.

Now termux is also available from Google's play store but Google forced it to remove it's SMS and GPS services threatening otherwise the whole app will be removed from play store. So don't bother with the play store version, if you indeed want the full automation.

Termux is a full fledged linux server giving you ssh access over net from outside. Has bash shell and a deb package manager.

3. Install termux-api from f-droid

This is a second package which bridges between the termux and the phone-api. You need to set permissions for this app in your phone.

4. Go to App Permissions on your phone and permit termux-api SMS, Phone and GPS access.

5. From Termux shell install package "apt install termux-api" again.

You need both. The shell version and the f-droid installation.

6. Now send SMS running

termux-sms-send -n 019xxxxxx 'Test SMS'

Your SMS will be delivered to the recipient and also appear inside your "Sent SMS" box.

7. To send from your laptop/rasbperry pi/server

- Run command "passwd" and change password from the Termux terminal to something you remember.

  • Run "whoami" to check your username. Username differs across installations.
  • install and run sshd on the Termux terminal.
  • configure password-less ssh login on your laptop to the cell phone, port is 8022 and not default 22.

    And then run from your server's shell

    $ ssh cellphone ''termux-sms-send -n 019xxxxxx 'Test SMS'"

    And your message will be delivered.

    Just tried it now and it works.

    Also note that Termux has php python apache and bunch of every other programs to install and ease your life on the cell phone side.

    13-Dec-2020 12:10 am

  • Published
    13-Dec-2020