I have tried TrySystem, makes no change… everything acts the same…
The reason for the double up is purely for testing permissions and location etc. Was not sure if I could run a shell script or a command directly.
was expecting either to fail or work, where I would at least know what I am missing.
I updated the DialPlan, did a core reload and dialed the extensions:
[2015-11-25 12:10:01] NOTICE[25539]: pbx_spool.c:427 attempt_thread: Call completed to Local/s@tc-maint
== Spawn extension (tc-maint, s, 7) exited non-zero on ‘Local/s@tc-maint-00000964;2’
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Executing [111@from-internal:1] Wait(“SIP/210-00000094”, “1”) in new stack
– Executing [111@from-internal:2] TrySystem(“SIP/210-00000094”, “/home/asterisk/on.sh”) in new stack
– Executing [111@from-internal:3] TrySystem(“SIP/210-00000094”, “/usr/local/bin/tdtool --on 1”) in new stack
– Executing [111@from-internal:4] Verbose(“SIP/210-00000094”, “SUCCESS”) in new stack
SUCCESS
– Executing [111@from-internal:5] System(“SIP/210-00000094”, “whoami > /home/asterisk/textfile”) in new stack
– Executing [111@from-internal:6] Verbose(“SIP/210-00000094”, “SUCCESS”) in new stack
SUCCESS
– Executing [111@from-internal:7] Hangup(“SIP/210-00000094”, “”) in new stack
== Spawn extension (from-internal, 111, 7) exited non-zero on ‘SIP/210-00000094’
– Executing [h@from-internal:1] Hangup(“SIP/210-00000094”, “”) in new stack
== Spawn extension (from-internal, h, 1) exited non-zero on ‘SIP/210-00000094’
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Executing [112@from-internal:1] Wait(“SIP/210-00000095”, “1”) in new stack
– Executing [112@from-internal:2] TrySystem(“SIP/210-00000095”, “/home/asterisk/off.sh”) in new stack
– Executing [112@from-internal:3] TrySystem(“SIP/210-00000095”, “/usr/local/bin/tdtool --off 1”) in new stack
– Executing [112@from-internal:4] Hangup(“SIP/210-00000095”, “”) in new stack
== Spawn extension (from-internal, 112, 4) exited non-zero on ‘SIP/210-00000095’
– Executing [h@from-internal:1] Hangup(“SIP/210-00000095”, “”) in new stack
== Spawn extension (from-internal, h, 1) exited non-zero on ‘SIP/210-00000095’
Hi,
The tdtool command sends a command to a USB device that initiates operation of a remote switch. The application and hardware are matched.
If I uncomment lines 2 and 3, I can place another USB device in the system , I can communicate directly via serial to an Arduino.
I thought about user permissions…
When I issue ‘su asterisk’ and launch the shell scripts they work as user asterisk and everything works fine from the CLI.
Yes it works great. I use it all the time. We will need serious debugging on this. paste your asterisk log (not the console) when you run it (tail -f /var/log/asterisk/full).
The script is running, but you have permissions problems on the device itself to my opinion. Write a dial plan and integrate it with the sudoers file like that:
[from-internal-custom]
exten => 111,1,Answer()
same => n,TrySystem(/usr/local/bin/tdtool --on 1)
same => n,NoOp(Status of TrySystem is: ${SYSTEMSTATUS})
same => n,Hangup
After adding this to your extensions_custom.conf file please reload the Asterisk dial plan (asterisk -rx’dialplan reload’).
Do not forget to add these lines to the end of the sudoers file (visudo):
#Allow asterisk user to run tdtool command
Cmnd_Alias TDTOOL = /usr/local/bin/tdtool
asterisk ALL = NOPASSWD: TDTOOL
The output was in the on state.
When I dialed 112 it would not turn off as the dialplan was still pointing to the shell script.
So dialing 111 would not turn the output on as it was already on.
When I changed state manually via CLI, and tried again, I was able to turn the output on when I dialed 111.
That is when I realised I only changed the the 111 extension and not the 112.
Hope that makes sense
It was the last change you suggested that got it to function