2
votes

I'm trying to make run a SMS sending python script from PHP.

SendSMS.py:

#!/usr/bin/env python

import gammu

sm=gammu.StateMachine()
sm.ReadConfig()
sm.Init()

message={
        'SMSC':{'Location':1},
        'Text':'blah blah bllah',
        'Number':'xxxxxxxxx
}
sm.SendSMS(message)

when i run it from the terminal with "sudo" it doesnt work.But works fine without "sudo"

the error:

gammu.ERR_DEVICENOTEXIST: {'Text': u"Error opening device, it doesn't exist.", 'Code': 4, 'Where': 'Init'}

I want to run the SMS script from a php script using shell_exec(). The problems are:

  1. I cant run the SMS script with sudo

  2. I cant run it through php without sudo

Please tell me how to fix this

Device-Raspberry pi 3

OS- Raspbian

1

1 Answers

1
votes

Most likely it doesn't find the configuration file, by default it's searched in user home directory which is different when executed through sudo.

You can specify path to configuration file on command line however it's better to not execute gammu as root and configure the device to be accessible by user.