Advertisement

05.25.2008 at 09:19AM PDT, ID: 23431354
[x]
Attachment Details

How do I scan multiple upper or lower cases in string variables.

Asked by Eggpatch in Bourne-Again Shell (bash), Linux Programming, Global System for Mobile Communications (GSM)

Tags:

Hello Im trying to develop my first custom event handler on a SMS message that will scan incoming text with different cases of string "KEY", "key" or "Key". This project is running on a linux machine and using a simple bash script only.  How do I scan or trigger any one of the string returning TEXT="Your Good!". Should i convert scanned string all to uppercase(lowercase) or should i declared all strings in arrays or should i use a conditional loop?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
#!/bin/sh
#
#Search the code Key, KEY or key inside the message.
#
#CODE that we want to search
SEARCH= Key | key | KEY
#
#Text message that we want to send
TEXT="Your Good!"
#
#
CODE=`/bin/cat $FILE | grep "$SEARCH"`
#
#if code is not empty reply with the message "Your Good!"
if [ "$CODE" == "$SEARCH" ]; then
        echo "$TEXT"
fi
[+][-]05.25.2008 at 09:30AM PDT, ID: 21643086

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Bourne-Again Shell (bash), Linux Programming, Global System for Mobile Communications (GSM)
Tags: Linux, Scripting, Bash
Sign Up Now!
Solution Provided By: mcuk_storm
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.25.2008 at 02:28PM PDT, ID: 21643694

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628