[asterisk-users] Execute a script outside Asterisk

Danny Nicholas danny at debsinc.com
Wed Jan 23 09:29:56 CST 2013


Here is the way I got it to do what I think you want.

  '1250' =>         1. answer()
[pbx_config]

                    2. setMusiconhold(jazz)
[pbx_config]

                    3. AGI(wait10.sh)
[pbx_config]

                    4. playback(vm-goodbye)
[pbx_config]

                    5. setMusiconhold(monkey)
[pbx_config]

                    6. system("/var/lib/asterisk/agi-bin/wait10.sh &")
[pbx_config]

                    7. playback(vm-goodbye)
[pbx_config]

                    8. hangup()
[pbx_config]

 

Without the &, AGI and system both execute and wait for completion of
wait10.sh.  with the &, the system command returns control to the dialplan
immediately.

 

From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Jonas Kellens
Sent: Wednesday, January 23, 2013 8:54 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] Execute a script outside Asterisk

 

Hello,

will this : 

Exten => 2,n,playback(vm-goodbye)

be executed even when 

Exten => 2,1,system(Jonas.php)

is still executing ??


The exact snippet would be :


Exten => s,1,answer()
Exten => s,n,system(Jonas.php) ; script that may take a minute
Exten => s,n,do something
Exten => s,n,Dial(SIP/peer1,,10) ; dial peer 1
Exten => s,n,system(Jonas.php) ; script that may take a minute
Exten => s,n,do something
Exten => s,n,Dial(SIP/peer2,,10) ; dial peer 2
Exten => s,n,system(Jonas.php) ; script that may take a minute
Exten => s,n,do something
Exten => s,n,Dial(SIP/peer3,,10) ; dial peer 3
Exten => s,n,hangup()

The peer MUST be dialed even if the script Jonas.php is still running.


Jonas.



On 01/23/2013 03:44 PM, Danny Nicholas wrote:

Let's assume you're using this snippet

[default]

Exten => s,1,answer()

Exten => s,n,playback(tt-monkeys)

Exten => s,n,waitexten(6)

Exten => s,n,hangup()

Exten => 1,1,AGI(Jonas.php)

Exten => 1,n,playback(vm-goodbye)

Exten => 1,n,hangup()

Exten => 2,1,system(Jonas.php)

Exten => 2,n,playback(vm-goodbye)

Exten => 2,n,hangup()

 

Both of these do the exact same thing - pick up the line, play tt-monkeys,
run Jonas.php if you press 1 or 2, play vm-goodbye and hangup.  The failure
of Jonas.php due to database or any other problem would not affect the
execution of the dialplan.

 

From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Jonas Kellens
Sent: Wednesday, January 23, 2013 8:32 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] Execute a script outside Asterisk

 

Hello,

thank you for your answer.

The most important here is that Asterisk continues with the rest of the
dialplan, in case the database-connection fails or hangs or ...

I don't think the System()-command makes this true.



Jonas.





On 01/23/2013 03:27 PM, Danny Nicholas wrote:

I would vote for system() on two accounts.  #1 AGI requires more overhead
and protocol #2 you are not expecting a result to return to the dialplan. 

 

From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Jonas Kellens
Sent: Wednesday, January 23, 2013 4:10 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: [asterisk-users] Execute a script outside Asterisk

 

Hello,

at certain time inside my dialplan I would like to have an external php
script executed. Asterisk should not wait for the end of the execution to
continue with the rest of the dialplan. It should just start the execution
of the php script (which inserts an entry into a remote mysql-DB).

What is the best way to work ?

- with AGI inside the dialplan ?
- with the system()-command inside the dialplan ?



Kind regards,
Jonas.







--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello
 
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

 






--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello
 
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130123/614e7685/attachment.htm>


More information about the asterisk-users mailing list