Script that performs action when receiving an SMS.


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 3 Weeks Ago
Script that performs action when receiving an SMS.

My case is the following: -I have a Linux system where I have an smsd installed (SmsTools3)

-This system works through a GSM module in which I can send and receive text messages.

-Text messages arrive in a certain folder (/ var / spool / sms / incoming)

-I need a script that does different things in response to an incoming SMS to the "Incoming" directory.



The idea is that each time an SMS arrives, the system analyzes the folder where these messages are received, choose the most RECENT message and execute an action on the system. What I have at the moment is this:

-------------------------------------------------- -------------------------------------------------- --------------------------------------------------
Code:
<#! / bin / bash
  #Declaration 



DIRECTORY = / var / spool / sms / incoming 

PATRON = 'Reset'
 

# Search 

ls -lt $ DIRECTORY && grep -iqrl $ PATRON $ DIRECTORY / * 



if [$? -eq 0]; then 

PLACE = $ (grep -irl $ PATRON $ DIRECTORY / *) 

echo "The pattern $ PATRON was located at $ PLACE." 

else 

echo "The pattern $ PATRON was not found in the files present within $ DIRECTORY." 

fi>

-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -
ANSWER:
Code:
root @ AcerNitro5: / home / halley # ./script3.sh
 total 8 -rw-r - r-- 1 root root 54 Mar 1 11:07 test2 -rw-r - r-- 1 root root 74 Mar 1 10:18 test1

The Reset pattern was located in / var / spool / sms / incoming / test 2 / and var / spool / sms / incoming / test2.
-------------------------------------------------- -------------------------------------------------- --------------------------------------------------
- I still have a lot to complete ... I'm a little lost on how to make the script select the text file (SMS incoming incoming) more RECENT where there is a pattern "Reset" and then run a reboot to the system.




Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 3 Weeks Ago at 01:18 PM.. Reason: Added CODE tags.
# 2  
Old 3 Weeks Ago
Welcome to the forum.


A few comments first:
- Please use code tags to improve readability and understandability of your code and data.
- exercise utmost care when composing your spec: a leading (or missing) slash can make a huge difference in the functioning (or mal-) of your script (here: /var vs var)
- WAY too many spaces. Your code given above will not run. NO spaces around = and / , and following $ . Too few around [ and ] .



When reading your request, my first thought was: a system like that should have hooks (or so) to trigger actions on events like incoming mail. Et voila, from the project homepage:

Quote:
The program can be run as a SMS daemon which ... can run other external programs or scripts after events like reception of a new message ...
Did you consider that functionality, which is to be preferred over repeatedly listing directory contents?
# 3  
Old 2 Weeks Ago
No, do not consider it because I am a beginner in these subjects. I regret violations of the rules, but if I made myself understood, I would like to know how to do what you tell me.
# 4  
Old 2 Weeks Ago
I'm afraid I can't give you more than general hints as I don't know the product. I found the "trigger external program" feature mentioned by just glancing at their web page. How about working from the ground up - read the product's man page, web site, look into the samples given, and try setting up a test system, managing / modifying the configuration until satisfied?

Last edited by RudiC; 2 Weeks Ago at 04:51 PM..
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
How do I generate a script with an inverse action? Braveheart UNIX for Beginners Questions & Answers 3 11-30-2016 10:47 AM
Script performs the right task but fails against check Ezraek Homework & Coursework Questions 5 12-05-2014 06:47 PM
Need shell script for SMS via telnet command wasay Shell Programming and Scripting 1 02-18-2014 09:23 PM
Sending sms through Shell script gargidas15 Shell Programming and Scripting 1 08-07-2013 04:49 AM
Script to performs checks sv0081493 Shell Programming and Scripting 4 10-09-2012 11:12 AM
Bash script to send SMS blackzeus Shell Programming and Scripting 2 12-20-2011 09:00 AM
Help with SMS sending Script thinktank Solaris 5 09-26-2011 10:11 AM
Monzy performs kill -9 at Stanford nigelc What is on Your Mind? 1 09-13-2010 02:14 AM
Need help with SMS script... Bruce1969 Shell Programming and Scripting 0 08-30-2010 03:07 PM
run a perl.script upon receiving an email in Sendmail manustone UNIX for Dummies Questions & Answers 0 07-16-2009 03:21 AM
shell script receiving variable and doing mathematical function damansingh Shell Programming and Scripting 3 05-23-2008 02:52 AM
sending sms through shell script alpareshamwala HP-UX 1 02-20-2008 07:37 AM
Sending SMS Via Unix Script? Omkumar Shell Programming and Scripting 2 08-27-2007 08:36 AM
Unix shell Script To Send SMS sdcoms UNIX for Advanced & Expert Users 1 05-16-2007 11:01 AM