+7 votes
1.2k views
in Linux by (11.7k points)
Hi, I have been told that there is the possibility to send SMS to mobile from a computer running Linux. They said it was easy. I have a server with CentOS Linux Minimal 6 (which does not carry the graphics mode) and want to make a script to send an SMS to a mobile when the team has the lower free RAM to a certain value. The memory I have solved with free linux command, but shipping SMS I have no idea how.

1 Answer

+8 votes
by (10.4k points)
Several wrote:
Hi, I have been told that there is the possibility to send SMS to mobile from a computer running Linux. They said it was easy. I have a server with CentOS Linux Minimal 6 (which does not carry the graphics mode) and want to make a script to send an SMS to a mobile when the team has the lower free RAM to a certain value. The memory I have solved with free linux command, but shipping SMS I have no idea how.
 



Indeed it is not very difficult to send SMS from a mobile computer with Linux. You will need, yes, the following: * SIM card operational mobile that allows sending SMS, the typical card that gets mobile. * Modem GSM USB: you'll have to purchase a GSM modem is a device where your inserted SIM card and you will connect via USB to your Linux server. Always acquires a GSM modem that is compatible with Linux. Once you have the SIM card and the GSM modem, plug it into the USB port on the server, wait a few seconds for it to detect and follow these steps: 1. Check that Linux has detected the GSM modem. Once connected linux run the following command: 
 

Code:

dmesg 



We will return all events that have occurred at the level of system diagnostics, so there you detect USB connected GSM modem will appear like this: usb 2-2: New USB device found, idVendor = 0f94, idProduct = 0005 usb 2-2: New USB device strings: Mfr = 1, Product = 2, SerialNumber = 3 usb 2-2: Product: Falcom SAMBA usb 2-2: Manufacturer: Falcom usb 2-2: SerialNumber: F0012333 usb 2-2 : configuration # 1 chosen.SQL from one choice ftdi_sio 2-2: 1.0: FTDI USB Serial Device converter detected usb 2-2: Detected FT8U232AM usb 2-2: Number of endpoints 2 usb 2-2: Endpoint 1 MaxPacketSize 64 usb 2-2 : Endpoint 2 MaxPacketSize 64 usb 2-2: Setting MaxPacketSize 64 ftdi_sio ttyUSB0: Unable to read latency timer: -32 usb 2-2: FTDI USB Serial Device converter now attached to ttyUSB0 ftdi_sio ttyUSB0: Unable to write latency timer: -32 ftdi_sio ttyUSB0: Unable to write latency timer: -32 In the example we see that detects the GSM modem connected Falcom brand to see more data on the device, we must first see which port is connected with the following command: 

 

Code:

lsusb 



It will show something like this: Bus 001 Device 001: ID 1d6b: 0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b: 0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b: 0001 Linux Foundation 1.1 root hub Bus 004 Device 001 : ID 1d6b: 0001 Linux Foundation 1.1 root hub Bus 002 Device 003: ID 0f94: 0005 Bus 003 Device 002: ID 046d: C312 Logitech, Inc. DeLuxe 250 Keyboard Bus 003 Device 003: ID 046d: C018 Logitech, Inc. Optical Wheel Mouse In our case the device is the Bus 002 Device 003: ID 0f94: 0005 since it coincides with the 0f94 ID idVendor the dmesg command. So we know who is in the bus device 002 and 003, for display more details about this device: 

 

Code:

find / dev / bus 



We show something to see the details of our GSM modem (the device Bus 002 Device 003) execute the following command: 

 

Code:
lsusb -D / dev / bus / usb / 002/003



That will return something like: Device: 0f94 ID: 0005 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0f94 idProduct 0x0005 bcdDevice 2.00 iManufacturer 1 iProduct 2 iserial 3 bNumConfigurations 1 Configuration Descriptor : bLength 9 bDescriptorType 2 wTotalLength 32 bNumInterfaces one bConfigurationValue one IConfiguration 0 bmAttributes 0xa0 (Bus Powered)Remote Wakeup MaxPower 498mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 255 Vendor Specific Subclass 255 Vendor Specific bInterfaceProtocol Protocol IInterface 2 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Device Status: 0x0003 Self Powered Remote Wakeup Enabled 2. Once detected the USB GSM modem, install the package that will allow us to send SMS in our Linux to do so, in the case of Linux CentOS can use "yum", the command would be: 

 

Code:

yum install smstools 


Once the smstools package installed, configure by editing "/etc/smsd.conf" with the command: 



Code:

nano /etc/smsd.conf 



An example of the contents of this configuration file: Example smsd.conf. Read the Manual for a description GSM1 devices = logfile = /var/log/smsd/smsd.log loglevel = 10 user = smstools infofile = /var/run/smsd/smsd.working pidfile = / var / run / SMSD / SMSD. pid # 3.1.5 Introduced smart logging # eleven your configuration is OK, set log level lower (5 is good in most cases) smart_logging = yes [GSM1] device = / dev / ttyUSB0 incoming = no pin = XXX As we see, some values important configuration file are: pin = XXX -> If we PIN on the SIM card GSM modem we noted in this parameter, otherwise we will comment the line leaving PIN: #pin = XXX or eliminating it directly. In the configuration file we also indicate the device to be used for sending SMS on line: device = / dev / ttyUSB0 And also tell us the location of the log file, needed for a possible consultation on error in sending SMS : logfile = /var/log/smsd/smsd.log 3. After connecting the GSM modem, smstools installed and configured the package, we will restart the service "SMSD" and do a test. To restart the service SMSD execute the command: 

 

Code:

/etc/init.d/smsd 


To test sending SMS execute the command: 



Code:

smssend 34XXX "Try sending SMS WikiTechSolutions" 



If everything is correct in seconds the SMS to the number indicated in "XXX" where 34 is the country code we arrive. It will return something like: - Text: Try sending SMS AjpdSoft To: 34XXX In the log file /var/log/smsd/smsd.log we see the result of the execution of the previous command SMS: 09/29/2014 11: 50: 04.5, SMSD: Moved file / var / spool / sms / outgoing / send_sMsjfE to / var / spool / sms / checked 29/09/2014 11: 50: 05.6, GSM1: I have to send one short message for / var / spool / sms / checked / send_sMsjfE 09/29/2014 11: 50: 05.6, GSM1: Sending SMS from to 34XXX 09/29/2014 11: 50: 05.6, GSM1: Checking if modem is ready 09/29/2014 11: 50: 06.7, GSM1: -> AT 29/09/2014 11: 50: 06.7, GSM1: Command is sent, waiting for the answer 29/09/2014 11: 50: 06.7, GSM1: <- OK AT 29/09/2014 11: 50: 06.6, GSM1: Pre-initializing modem 09/29/2014 11: 50: 06.7, GSM1: -> CMEE ATE0 + = 1; + CREG = 2 09/29/2014 11: 50: 06.7, GSM1: Command is sent, waiting for the answer 09/29/2014 11: 50: 07.7, GSM1: <- CMEE ATE0 + = 1; + CREG = 2 OK 29/09/2014 11: 50: 07.7, GSM1: -> AT + CSQ 29/09/2014 11: 50: 07.7, GSM1: Command is sent, waiting for the answer 29/09/2014 11: 50: 07.7, GSM1: <- + CSQ: 26,99 OK 09/29/2014 11: 50: 07.6, GSM1: Signal Strength Indicator (26, 99) -61 dBm (Excellent), Bit Error Rate: not kn $ 09/29/2014 11: 50: 07.6, GSM1: Checking if Modem is registered to the network 09.29.2014 11:50:07, 7 GSM1: -> AT + CREG? 09/29/2014 11: 50: 07.7, GSM1: Command is sent, waiting for the answer 09/29/2014 11: 50: 08.7, GSM1: <- + CREG: 2,1, "0BBD", "1184" OK 29/09/2014 11: 50: 08.6, GSM1: Modem is registered to the network 29/09/2014 11: 50: 08.6, GSM1 : Selecting PDU mode 09/29/2014 11: 50: 08.7, GSM1: -> AT + CMGF = 0 29/09/2014 11: 50: 08.7, GSM1: Command is sent, waiting for the answer 2014 -09 to 29 11: 50: 08.7, GSM1: <- OK 09/29/2014 11: 50: 08.7, GSM1: -> AT + CMGS = 36 29/09/2014 11:50:08, 7 GSM1: Command is sent, waiting for the answer 09/29/2014 11: 50: 09.7, GSM1: <-> 29/09/2014 11: 50: 09.7, GSM1: -> 0011000B914386FF079BD2C736A7AEEBECD74 ^ Z 29/09/2014 11: 50: 09.7, GSM1: Command is sent, waiting for the answer 29/09/2014 11: 50: 13.7, GSM1: <- + CMGS 12 OK 29/09/2014 11: 50: 13.5, GSM1: SMS sent, Message_id: 12 To:. 34XXX, sending time 8 sec 09/29/2014 11: 50: 13.6, GSM1: Deleted file / var / spool / sms / checked / send_sMsjfE As we see in the log file, the smssend application uses AT commands to connect to the GSM modem, first check that the modem is initialized, you have coverage, which is registered to a valid network telephony and if everything is correct the sending of SMS.

Ask a Question
Welcome to WikiTechSolutions where you can ask questions and receive answers from other members of the community.

You can ask a question without registration.

Categories

...