Need help getting trixbox to run linux program

twoskinsoneman
Posts: 17
Member Since:
2008-09-19

I've got a working program I use to access the parallel printer port.
From the command prompt I type ./program 0xff
and I get an output to my port.
I type ./program 0x00 and the output is removed.

What I want is to have trixbox run this program in response to a dialed ext. Basicaly pick up phone, dial 333 and trixbox runs the linux command ./program 0xff thereby turning on the port output.
Here is what I have tried
adding this to the extensions_custom.conf file
[from-internal-custom]
exten => 333,1,system(./lptout 0xff)
exten => 444,1,system(./lptout 0x00)

when I try dialing 333 this is what I get

trixbox1*CLI>
-- Starting simple switch on 'Zap/1-1'
-- Executing [333@from-internal:1] System("Zap/1-1", "./lptout 0xff") in new stack
== Spawn extension (from-internal, 333, 1) exited non-zero on 'Zap/1-1'
-- Executing [h@from-internal:1] Macro("Zap/1-1", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] ResetCDR("Zap/1-1", "w") in new stack
-- Executing [s@macro-hangupcall:2] NoCDR("Zap/1-1", "") in new stack
-- Executing [s@macro-hangupcall:3] GotoIf("Zap/1-1", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,6)
-- Executing [s@macro-hangupcall:6] GotoIf("Zap/1-1", "1?skipblkvm") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s@macro-hangupcall:9] GotoIf("Zap/1-1", "1?theend") in new stack
-- Goto (macro-hangupcall,s,11)
-- Executing [s@macro-hangupcall:11] Hangup("Zap/1-1", "") in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'Zap/1-1' in macro 'hangupcall'
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'Zap/1-1'
-- Hungup 'Zap/1-1'

Any Help?
Thanks



andrew
Posts: 1472
Member Since:
2006-05-30
You need some more code

try something like this

exten => 333,1,Answer
exten => 333,n,Wait(1)
exten => 333,n,system(/usr/local/sbin/lptout 0xff)
exten => 333,n,Playback(port-activated)
exten => 333,n,Hangup

You have to answer the call first and you need to full path of the application you are calling with system().

try voip-info.org they are a great resource for Asterisk dialplan.



twoskinsoneman
Posts: 17
Member Since:
2008-09-19
please. a little more patients

Thanks andrew. I'm new to Asterisk and I am trying to grasp the concepts. I'm going through Asterisk the Future or Telephony but it is slow coming.

I added the additional code you offered. Aside from me needing to learn the code better do you have any idea why the system command isn't getting through.
If I'm in the /usr/local/sbin/ directory and type "lptout 0xff" it works perfect. But when I dial 333 I get this

-- Starting simple switch on 'Zap/1-1'
-- Executing [333@from-internal:1] Answer("Zap/1-1", "") in new stack
-- Executing [333@from-internal:2] Wait("Zap/1-1", "") in new stack
-- Executing [333@from-internal:3] System("Zap/1-1", "/usr/local/sbin/lptout 0xff") in new stack
-- Executing [333@from-internal:4] Playback("Zap/1-1", "port-activated") in new stack
-- Executing [333@from-internal:5] Hangup("Zap/1-1", "") in new stack
== Spawn extension (from-internal, 333, 5) exited non-zero on 'Zap/1-1'
-- Executing [h@from-internal:1] Macro("Zap/1-1", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] ResetCDR("Zap/1-1", "w") in new stack
-- Executing [s@macro-hangupcall:2] NoCDR("Zap/1-1", "") in new stack
-- Executing [s@macro-hangupcall:3] GotoIf("Zap/1-1", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,6)
-- Executing [s@macro-hangupcall:6] GotoIf("Zap/1-1", "1?skipblkvm") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s@macro-hangupcall:9] GotoIf("Zap/1-1", "1?theend") in new stack
-- Goto (macro-hangupcall,s,11)
-- Executing [s@macro-hangupcall:11] Hangup("Zap/1-1", "") in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'Zap/1-1' in macro 'hangupcall'
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'Zap/1-1'
-- Hungup 'Zap/1-1'



twoskinsoneman
Posts: 17
Member Since:
2008-09-19
bump

any help?



twoskinsoneman
Posts: 17
Member Since:
2008-09-19
bump

anyone please?



jades
Posts: 2340
Member Since:
2006-11-26
When you dial 333 apparently

When you dial 333 apparently it is using one of your zaptel trunks. If this is intentional that's one thing but if not, you need to go to your outbound routes and fix up your dial plans

--

Joseph Ades
josephades1_at_gmail_dot_com
(212) 937-4299



SkykingOH
Posts: 9681
Member Since:
2007-12-17
Go to the CLI and set debug

Go to the CLI and set debug to 20 and verbose to 20

Then check the log in /var/log/asterisk/full

It's something simple wrong, your syntax is correct although I would capatilize 'System'

Just to make sure it's working add a line like 333,n,System(touch /usr/local/sbin/testfile)

--

Scott

aka "Skyking"



twoskinsoneman
Posts: 17
Member Since:
2008-09-19
Thanks for the 'touch'

Thanks for the 'touch' command tip. I can see now that it is not working. I added a touch command and it is not changing the time stamp. I can't figure why though.
I don't see any errors... Just nothing happens.
This is my 'full' log after attempting the extension:
[root@trixbox1 ~]# tail -f /var/log/asterisk/full
[Jan 13 13:54:58] DEBUG[2865] app_macro.c: Executed application: GotoIf
[Jan 13 13:54:58] VERBOSE[2865] logger.c: -- Executing [s@macro-hangupcall:6] GotoIf("SIP/108-097e4b00", "1?skipblkvm") in new stack
[Jan 13 13:54:58] VERBOSE[2865] logger.c: -- Goto (macro-hangupcall,s,9)
[Jan 13 13:54:58] DEBUG[2865] app_macro.c: Executed application: GotoIf
[Jan 13 13:54:58] VERBOSE[2865] logger.c: -- Executing [s@macro-hangupcall:9] GotoIf("SIP/108-097e4b00", "1?theend") in new stack
[Jan 13 13:54:58] VERBOSE[2865] logger.c: -- Goto (macro-hangupcall,s,11)
[Jan 13 13:54:58] DEBUG[2865] app_macro.c: Executed application: GotoIf
[Jan 13 13:54:58] VERBOSE[2865] logger.c: -- Executing [s@macro-hangupcall:11] Hangup("SIP/108-097e4b00", "") in new stack
[Jan 13 13:54:58] VERBOSE[2865] logger.c: == Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/108-097e4b00' in macro 'hangupcall'
[Jan 13 13:54:58] VERBOSE[2865] logger.c: == Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/108-097e4b00'

This is the CLI read-out as I attempt it:
Asterisk 1.4.22-2 RPM by vc-rpms@voipconsulting.nl, Copyright (C) 1999 - 2008 Digium, Inc. and others.
Created by Mark Spencer
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 1.4.22-2 RPM by vc-rpms@voipconsulting.nl currently running on trixbox1 (pid = 2616)
Verbosity is at least 3
-- Executing [333@from-internal:1] Answer("SIP/108-097e4a98", "") in new stack
-- Executing [333@from-internal:2] Wait("SIP/108-097e4a98", "3") in new stack
-- Executing [333@from-internal:3] System("SIP/108-097e4a98", "touch /usr/local/sbin/lptout") in new stack
-- Executing [333@from-internal:4] System("SIP/108-097e4a98", "/usr/local/sbin/lptout 0xff") in new stack
-- Executing [333@from-internal:5] Wait("SIP/108-097e4a98", "3") in new stack
-- Executing [333@from-internal:6] Hangup("SIP/108-097e4a98", "") in new stack
== Spawn extension (from-internal, 333, 6) exited non-zero on 'SIP/108-097e4a98'
-- Executing [h@from-internal:1] Macro("SIP/108-097e4a98", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] ResetCDR("SIP/108-097e4a98", "w") in new stack
-- Executing [s@macro-hangupcall:2] NoCDR("SIP/108-097e4a98", "") in new stack
-- Executing [s@macro-hangupcall:3] GotoIf("SIP/108-097e4a98", "1?skiprg") in new stack
-- Goto (macro-hangupcall,s,6)
-- Executing [s@macro-hangupcall:6] GotoIf("SIP/108-097e4a98", "1?skipblkvm") in new stack
-- Goto (macro-hangupcall,s,9)
-- Executing [s@macro-hangupcall:9] GotoIf("SIP/108-097e4a98", "1?theend") in new stack
-- Goto (macro-hangupcall,s,11)
-- Executing [s@macro-hangupcall:11] Hangup("SIP/108-097e4a98", "") in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/108-097e4a98' in macro 'hangupcall'
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/108-097e4a98'



twoskinsoneman
Posts: 17
Member Since:
2008-09-19
More basic question

Just to make sure... am I puting this code in the right area? I'm puting it in the extensions_custom.conf in the [from-internal-custom] context.
Here's what the file looks like.

[root@trixbox1 ~]# cat /etc/asterisk/extensions_custom.conf
; This file contains example extensions_custom.conf entries.
; extensions_custom.conf should be used to include customizations
; to AMP's Asterisk dialplan.

; All custom context should contain the string 'custom' in it's name

; Extensions in AMP have access to the 'from-internal' context.
; The context 'from-internal-custom' is included in 'from-internal' by default

#include extensions_hud.conf

[from-internal-custom]
exten => 333,1,Answer
exten => 333,n,Wait(3)
exten => 333,n,System(touch /usr/local/sbin/lptout)
exten => 333,n,System(/usr/local/sbin/lptout 0xff)
exten => 333,n,Wait(3)
exten => 333,n,Hangup

1234,1,Playback(demo-congrats) ; extensions can dial 1234
;1234,2,Hangup()
;h,1,Hangup()
;include => custom-recordme ; extensions can also dial 5678

; custom-count2four,s,1 can be used as a custom target for
; a Digital Receptionist menu or a Call Group
;[custom-count2four]
;s,1,SayDigits(1234)
;s,2,Hangup

; custom-recordme,5678,1 can be used as a custom target for
; a Digital Receptionist menu or a Call Group
;[custom-recordme]
;exten => 5678,1,Wait(2)
;exten => 5678,2,Record(/tmp/asterisk-recording:gsm)
;exten => 5678,3,Wait(2)
;exten => 5678,4,Playback(/tmp/asterisk-recording)
;exten => 5678,5,Wait(2)
;exten => 5678,6,Hangup

[custom-meetme3]
exten => s,1,Answer
exten => s,n,Wait(3)
exten => s,n,CBMysql()
exten => s,n,Hangup



twoskinsoneman
Posts: 17
Member Since:
2008-09-19
resolved

In case anyone happens to come across this looking for similar help I will post my resolution.

This problem was a simple one. The file I was trying run was trying to access a device only root could access.
When I logged in as the user asterisk (su asterisk) I tried the run the program and received "Error: Couldn't get the port at ..."
So I guess there are multiple ways to get it to work such as changing the permissions for the device. I ended up changing the 'x' file permission of the program to 's' (chmod +s (filename)) This tells the program to run as the the file owner. This fixed my issue.

Thanks to those who bothered to respond to my thread.
I hope this helps someone in the future.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.