"Script that performs action when receiving an SMS."

Post #303031590 by dMihawkCL on Saturday 2nd of March 2019 12:05:11 PM

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:

-------------------------------------------------- -------------------------------------------------- --------------------------------------------------
<#! / bin / bash

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." 


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


-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -
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; 03-02-2019 at 02:18 PM.. Reason: Added CODE tags.

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sending SMS Via Unix Script?

Hi, Is it possible to send sms to a mobile from unix box using Shell Scripting? I really wonder if anyone can help me with some information regarding how to setup the environment if possible. Iam also searching and trying to setup the same. My Environment: HP-UX B.11.11 U 9000/800... (2 Replies)
Discussion started by: Omkumar
2 Replies

2. HP-UX

sending sms through shell script

pl. if any one can help me in this . i wouldlike to know if there is a way to send sms through unix box. i have tried using mailx option. but what type of servers will be required . if any one can give me references... Thankxs in advance Regards, Alpa (1 Reply)
Discussion started by: alpareshamwala
1 Replies

3. UNIX for Dummies Questions & Answers

run a perl.script upon receiving an email in Sendmail

Hi All I am newbie with Sendmail and Linux in general. We use sendmail for outgoing and incoming mails. Once our server receives a certain email xxx@yyy.com we would like to run a PERL script doing some task wiht it. Can you address me a little bit on that topic? In order to do that the... (0 Replies)
Discussion started by: manustone
0 Replies

4. Shell Programming and Scripting

Need help with SMS script...

I use the SMS script on this page: http://www.prescriptionpc.com/TEST_newpage1.html#section=sms The “functions” work fine, but after clicking “submit” and receiving the “thank you” message, nothing happens. I find it odd that I can send a text message to myself choosing my carrier (Virgin... (0 Replies)
Discussion started by: Bruce1969
0 Replies

5. Solaris

Help with SMS sending Script

I would like assistance on a script that could send a text message to my mobile phone when I run a command and the text should be send only if a condition is met. I want to have a cron-job running every 10 minutes to check the system for overload conditons with a command: more logfile.log | grep... (5 Replies)
Discussion started by: thinktank
5 Replies

6. Shell Programming and Scripting

Bash script to send SMS

Hey guys I was wondering how to go about creating a bash script to send SMS..any ideas are appreciated.. (2 Replies)
Discussion started by: blackzeus
2 Replies

7. Shell Programming and Scripting

Script to performs checks

Hi , I need a script which performs below activity I have one file named "testfile" in 9 different directories with same name. I want to perform below action with each testfile of each directory. if ; then mv listfiles listfiles_`date +%b%y` else echo No Such files fi ... (4 Replies)
Discussion started by: sv0081493
4 Replies

8. Shell Programming and Scripting

Sending sms through Shell script

Can anyone please help me to in scripting of sending sms through shell script (1 Reply)
Discussion started by: gargidas15
1 Replies

9. Homework & Coursework Questions

Script performs the right task but fails against check

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a script checkFiles.sh that takes an arbitrary number of file paths from the command line and carries ... (5 Replies)
Discussion started by: Ezraek
5 Replies

Featured Tech Videos

All times are GMT -4. The time now is 12:31 PM.
Unix & Linux Forums Content Copyright 1993-2019. All Rights Reserved.
Privacy Policy