When caller hangs up, hangup.agi does not properly execute (appears to prematurely terminate). When callee hangs up hangup.agi executes fine. [custom-out] exten => s,1,Answer exten => s,n,Playback(custom/Nextoperator) exten => s,n,SetMusicOnHold(fun) exten => s,n,AGI,uuid.agi exten => s,n,Set(callid=${CALLERID(num)}_${uuid}) exten => s,n,AGI,recordid.agi|${callid} exten => s,n,Set(CDR(userfield)=${callid}) exten => s,n,Set(CDR(accountcode)=${recordid}) exten => s,n,Monitor(wav,/mnt/rd/recording/${callid},mb) exten => s,n,ForkCDR exten => s,n,Dial(SIP/${dialnum}@vitel-outbound,,mghHwWM(record|${recordid})) exten => s,n,AGI,hangup.agi|${recordid} exten => h,1,AGI,hangup.agi|${recordid} [macro-record] exten => s,1,AGI,playdigits.agi|${ARG1} exten => s,n,ResetCDR #!/usr/bin/perl -w #hangup.agi use Asterisk::AGI; my $AGI = new Asterisk::AGI; # Ignore hangup signal from Asterisk $SIG{HUP} = "IGNORE"; ($query)=@ARGV; # Create an LWP UserAgent to access the web require HTTP::Request; use LWP::UserAgent; my $browser = LWP::UserAgent->new; # Get the page my $url = "http://www.example.com/lmt/call_end.asp?rec=$query"; my $request = HTTP::Request->new("GET",$url); my $response = $browser->request($request); print STDERR $response->as_string . "\n"; print STDERR "URL: " . $url . "\n"; exit(0); This is the output when the caller hangs up... -- AGI Script playdigits.agi completed, returning 0 -- Executing ResetCDR("SIP/vitel-outbound-086367d8", "") in new stack -- Stopped music on hold on SIP/aydiosmio-0862aa78 == Spawn extension (custom-out, s, 11) exited non-zero on 'SIP/aydiosmio-0862aa78' -- Executing AGI("SIP/aydiosmio-0862aa78", "hangup.agi|119") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/hangup.agi AGI Tx >> agi_request: hangup.agi AGI Tx >> agi_channel: SIP/aydiosmio-0862aa78 AGI Tx >> agi_language: en AGI Tx >> agi_type: SIP AGI Tx >> agi_uniqueid: 1172789505.0 AGI Tx >> agi_callerid: 2125551100 AGI Tx >> agi_calleridname: 2125551100 AGI Tx >> agi_callingpres: 0 AGI Tx >> agi_callingani2: 0 AGI Tx >> agi_callington: 0 AGI Tx >> agi_callingtns: 0 AGI Tx >> agi_dnid: unknown AGI Tx >> agi_rdnis: unknown AGI Tx >> agi_context: custom-out AGI Tx >> agi_extension: h AGI Tx >> agi_priority: 1 AGI Tx >> agi_enhanced: 0.0 AGI Tx >> agi_accountcode: 119 AGI Tx >> == Spawn extension (custom-out, h, 1) exited non-zero on 'SIP/aydiosmio-0862aa78' == Parsing '/etc/asterisk/extconfig.conf': Found == Parsing '/etc/asterisk/manager.conf': Found == Parsing '/etc/asterisk/manager_custom.conf': Found == Parsing '/etc/asterisk/enum.conf': Found == Parsing '/etc/asterisk/rtp.conf': Found == RTP Allocating from port range 10000 -> 20000 == Parsing '/etc/asterisk/dnsmgr.conf': Found -- Reloading module 'res_musiconhold.so' (Music On Hold Resource) == Parsing '/etc/asterisk/musiconhold.conf': Found == Parsing '/etc/asterisk/musiconhold_additional.conf': Found -- Reloading module 'res_features.so' (Call Features Resource) == Parsing '/etc/asterisk/features.conf': Found == Remapping feature Blind Transfer (blindxfer) to sequence '##' == Remapping feature Disconnect Call (disconnect) to sequence '**' == Remapping feature One Touch Monitor (automon) to sequence '*1' -- Added extension '700' priority 1 to parkedcalls -- Reloading module 'res_indications.so' (Indications Configuration) -- Unregistered indication country 'at' [redacted] -- Unregistered indication country 've' == Parsing '/etc/asterisk/indications.conf': Found -- Registered indication country 'at' [redacted] -- Registered indication country 've' -- Setting default indication country to 'us' -- Reloading module 'res_crypto.so' (Cryptographic Digital Signatures) -- Reloading module 'res_adsi.so' (ADSI Resource) asterisk1*CLI>