1

I wonder if it is possible from a SH script on my local computer, publishing content on a remote installation of drupal.

Why have a gammu sms gateway and when a new sms on my local computer I want to be published in my drupal page.

This is an example of a script that warns of a new sms

    #!/bin/sh
INBOX=/path/to/smsd/inbox
PROGRAM=/bin/cat
for ID in "$@" ; do
    $PROGRAM < $INBOX/$ID
done

Could you do something similar to send this SMS to my remote drupal page?

3
  • It would be much easier to send the SMS to your server which would trigger a PHP script, which you can then just do what ever you want depending on how you want to do it. Rather then go from your local computer -> remove server.
    – Steven
    Commented Mar 31, 2014 at 17:56
  • The problem is that my remote server does not allow me to install a physical GSM modem And the GSM modem to receive this message on my local computer
    – laur
    Commented Mar 31, 2014 at 18:02
  • Okay then expose your script to the web and post the SMS results to the URL. Or send an email, or any other method that can be used to transfer data from one computer to another :)
    – Steven
    Commented Mar 31, 2014 at 18:06

3 Answers 3

1

If you need to receive the sms on your local computer, and wish to create a new node on your production server using ssh rather than web APIs, then I would recommend that you do this with a custom Drush command that you write.

Start off by installing the drushify command on your local system (drush dl drushify).

Define the options and arguments for your command; for example, you might want to put the contents of the sms message in the command argument (name the argument variable $body), and specify any metadata in the options.

Next, fill in the implementation of your Drush command with your own code. This will look something like:

$node = new stdClass();
$node->type = 'my_sms_content_type'; // presumes you already made one of these with cck
node_object_prepare($node);
$node->body[$node->language][] = array('value' => $body, 'format' => 1);
$node->status = TRUE;
node_save($node);

Test the command locally with drush @mysite.dev sms-add "Test sms"

When satisfied, copy the Drush command to $HOME/.drush on the remote machine (where $HOME is the home folder of the remote user you define in your Drush alias), put a ssh public key in the appropriate .ssh directory, and run the command remotely with drush @mysite.live sms-add "Test sms". Be sure to run drush cc drush when adding new Drush commands.

Your script then becomes:

for ID in "$@" ; do
    drush @mysite.live sms-add "$(cat $INBOX/$ID)"
done

You might be able to replace the custom Drush command with Drush Entity. Give it a try.

1

Do you already know this module : https://drupal.org/project/gammu
It seems to fit your needs :

This module support Gammu database using same or separate Drupal database, even located on different server.

And it's provide with example.

Hoping that help.

1
  • This module only serves to receive and send SMS from drupal, really does not make a sms a node. thanks
    – laur
    Commented Mar 31, 2014 at 18:11
1

See also: Code Server - https://www.drupal.org/project/codeserver

Code Server provides a framework for calling PHP functions on a Drupal site from code running on a different Drupal site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.