niju
niju

Reputation: 5

Asterisk (raspbx): py script - open asterisk CLI and fire command

I'm trying to send SMS from a python script over asterisk to my Smarphone. I've installed RasPBX on a Raspberry 3 with chan_dongle.

Manually it works fine:

asterisk -vvvr

and then

dongle sms dongle0 +4178xxxxxxx Hello, nice weather today

My idea was to write a python script to open the asterisk cli and type in the command to send the sms.

like this:

import os
import time

os.system("asterisk -vvvr")
time.sleep(2)
os.system("dongle sms dongle0 +4178xxxxxxx Hello, nice weather today")

but it didn't work! can anyone help me?

thank you. greetings from switzerland (where the weather isn't nice today)

Upvotes: 0

Views: 717

Answers (1)

arheops
arheops

Reputation: 15259

You should do something like this:

asterisk -rx "core show channels"

-x command Connect to a running Asterisk process and execute a command on a command line, passing any output through to stan‐ dard out and then terminating when the command execution completes. Implies -r when -R is not explicitly supplied.

Upvotes: 1

Related Questions