/* DESC: This script send a SMS received by a TCP message "<number>:<text>" * Don't forget to configure and enable the SMS service first * The number format is international e.g. +4912345678 * * Copyright (C) 2017 NetModule AG, Switzerland (rfa) */ PORT = 2000; if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) exit(1); if (bind(s, PORT, "") == -1) exit(2); if (listen(s, 1) == -1) exit(3); while (true) { if (c = accept(s)) { while (true) { if ((r = select(c, 10)) == - 1) exit(4); if (r == 0) continue; m = recv(c); if (p = strchr(m, ":")) if (nb_sms_send(left(m, p), right(m, strlen(m) - p - 1))) send(c, "Spooled\n"); else send(c, "Error\n"); } } } /* not reached */