[solved] Schedule message to run sms command

I can schedule a SMS message to be send at specific time, BUT Is there any possibility to schedule a sms to run any ‘SMS COMMAND’ ?

For example,
I want to run the playsms SMS COMMAND daily at 9, possible?

Sorry, this isn’t clear to me :smiley:

SMS Command is an incoming feature, a feature that is driven by incoming SMS. Not sure how to schedule it.

anton

Ok let me explain more to better understand the situation.

I have SMS Command (for incoming sms) configured to execute an local bash script which collects different stats from different servers, then it reply back the results to a specific mobile number.

I somehow want playSMS to schedule this script to run and reply back the collected result to mobile number.

OR can you assist that is there any way I can run playsms sms command via CLI ?

The reason I am prefering playSMS is that it can send sms with any format like spaces / line break etc,
while if i simply cron schedule teh script, the kannel will not accept spaces\linebreaks etc. I have to do lot of manual work to replace things, thats why i want play sms to schedule the script and run.

So you want to run a shell script that collect different stats from different servers and send them to specific mobile number.

What if you create a PHP CLI script (PHP that will be run on Linux console) that run your stat shell script and pass the value through playSMS HTTP API (or Kannel) ?

anton

I dont have experience with the PHP so the issue will be same howto pass message to kannel as message example is as follow

line1 with few special charcaters
line 2 spaces words etc
line 3 "special characters like > / , . " 
end

how to pass this to KANNEL via bash or php?

Let me write an example (untested):

scheduler.php:

#!/usr/bin/php -q
<?php

// your playSMS username
$username = 'admin';

// your webservices token (my account -> user config)
$token = '1194df9e20d06c3790f0c6fef49f174a';

// playSMS Web Services URL
$playsms_ws = 'http://localhost/playsms/index.php?app=ws';

// destination numbers, comma seperated or use #groupcode for sending to group
$destinations = '+6200123123123,+6200456456456';

// get stats data
$stats = shell_exec('/path/to/your/stat/shell/script/dot/sh');

// send via playSMS HTTP API
$ws = $playsms_ws . '&u=' . $username . '&h=' . $token . '&op=pv&to=' . urlencode($destinations) . '&msg=' . urlencode($stats) . '&nofooter=1';
$ret = @file_get_contents($ws);

echo $ret;

you need to chmod +x scheduler.php to run scheduler.php from Linux console:

chmod +x scheduler.php
./scheduler.php
1 Like

Dear Anton,

It worked Perfectly :blush:
Thank you very much for your assistance and support. :kissing_heart:

Just for the reference purposes.
https://aacable.wordpress.com/2015/07/30/playsms-send-sms-via-scriptcli-using-webservices-token/

cool :smile:

additional reference:
cli2sms.php: http://pastebin.com/Nxuw7jF9

1 Like

Updated. Thank you for your contributions :sunny:

Hi Anton , I’ve a similar issue but i want execute a php cli script on autoreply for example:

Client send SMS with this body: CONSULTA 123456 . Then on receive i want to autoreply sms to the sender number with the result of the query (that search 123456 on a local db mysql and return info like name or address )inside the php cli command. Thanks.

Hi, Anton!
Many thanks for help us with your knowledges.

Congratulations for your forum. I hope to get explain my doubts and respectfully I ask you support to solve these issues:

I’ve installed a smstools3 and PlaySMS prototype server like a begginer in gateways sms solutions.

How can I get my mobile numbers from data base and send to playSMS manage delivery of text messages?

After done all settings with playSMS and smstools, Is there risk of blocked mobile chip sending about 3000 sms a day or itself leads to manage the amount of sms and its breaks during the transfer without code programming?

Regards!

Hi Anton.

Thanks. It also worked for me.
But I didn’t understand the stats scope.

What does $stats mean? And, why I should I have to use it?

Thanks