is executable.
Then run 'agi debug' from the asterisk cli, place a call and see what
was
send and receive from your agi
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of James A.
Shigley
Sent: April-23-09 12:26 PM
To: asterisk-users at lists.digium.com
Subject: [asterisk-users] AGI PHP script
I have the below script that doesn't seem to be working. I don't know if
I
have something in the script wrong that I am just missing. Or if I don't
have the php.ini set correctly for emailing
This is the CLI output
-- Executing [4099XXXXXX at port3_real:1] Goto("DAHDI/50-1",
"newhire,s,1") in
new stack
-- Goto (newhire,s,1)
-- Executing [s at newhire:1] Ringing("DAHDI/50-1", "")
in new stack
-- Executing [s at newhire:2] Answer("DAHDI/50-1", "")
in new stack
-- Executing [s at newhire:3] Monitor("DAHDI/50-1",
"wav,/var/lib/asterisk/soun
ds/NewHire/Newhire-1240503071.15148-4099819213-s,o") in new stack
-- Executing [s at newhire:4] AGI("DAHDI/50-1",
"newhire.php") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/newhire.php
-- <DAHDI/50-1>AGI Script newhire.php completed, returning 0
-- Auto fallthrough, channel 'DAHDI/50-1' status is
'UNKNOWN'
-- Hungup 'DAHDI/50-1'
Here is the script
#!/usr/bin/php5
<?php
// Get AGI vars from *
$agivars = array();
while (!feof(STDIN)) {
$agivar = trim(fgets(STDIN));
if ($agivar === '') {
break;
}
$agivar = explode(':', $agivar);
$agivars[$agivar[0]] = trim($agivar[1]);
}
extract($agivars);
// Variable Declarations
$agi_uniqueid;
$agi_callerid;
$agi_calleridname;
$agi_extension;
$agi_uniqueid;
$UNIQUEID = $agi_uniqueid;
$CALLERID = $agi_callerid;
$EXTEN = $agi_extension;
$attachment
"/var/lib/asterisk/sounds/NewHire/Newhire-$UNIQUEID-$CALLERID-$EXTEN.wav";
$from = ". at xxx.com";
$to ="jas at answeringserv.com ";
$subject="New Applicant";
$headers = "From: $from";
$message ="$UNIQUEID , $CALLERID , $EXTEN , $attachment";
mail($to,$subject,$message,$headers);
?>
So is it anything obviously wrong with the script I'm missing?
Besides something not being configured in php.ini correctly any other ideas?
James Shigley
Monroe Telephone Answering Service
409-981-9213
Infinity 5.5,UC 4.02.3803, Blink 3.0.104
Ecreator:2.21, eResponse 1.1.7
Webportal,WebApps,
CONFIDENTIALITY NOTICE: This email, including any attachments, contains
information which may be confidential or privileged. The information is
intended to be for the use of the individual or entity named above. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution or use of the contents of this information is prohibited. If
you have received this email in error, please notify the sender immediately
by "reply to sender only" message and destroy all electronic and hard
copies
of the communication, including attachments.
"Common sense is the collection of prejudices acquired by age
eighteen." --
Albert Einstein
"Once you can accept the universe as matter expanding into nothing that is
something,wearing stripes with plaid comes easy." -- Albert Einstein
"I know a little of everything, but a lot of nothing"
--Boundary_(ID_K5GCuljoUugxYJE7QmfLGQ)
Content-type: text/html; charset=us-ascii
Content-transfer-encoding: 7BIT
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered
medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
{font-family:"Brush Script MT";
panose-1:3 6 8 2 4 4 6 7 3 4;}
@font-face
{font-family:"Bradley Hand ITC";
panose-1:3 7 4 2 5 3 2 3 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-CA link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='color:#1F497D'>First run
<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>/var/lib/asterisk/agi-bin/newhire.php<o:p></o:p></span></p>
<p class=MsoNormal><span
style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>From linux
command line to see
if you don’t have any error and that your AGI is
executable.<o:p></o:p></span></p>
<p class=MsoNormal><span
style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>Then run
‘agi debug’ from the
asterisk cli, place a call and see what was send and receive from your
agi<o:p></o:p></span></p>
<p class=MsoNormal><span
style='color:#1F497D'><o:p> </o:p></span></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm
0cm 0cm'>
<p class=MsoNormal><b><span lang=EN-US
style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span
lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>
asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] <b>On Behalf Of
</b>James A.
Shigley<br>
<b>Sent:</b> April-23-09 12:26 PM<br>
<b>To:</b> asterisk-users at lists.digium.com<br>
<b>Subject:</b> [asterisk-users] AGI PHP
script<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>I have
the below script that
doesn’t seem to be working. I don’t know if I have something
in the script
wrong that I am just missing. Or if I don’t have the php.ini set
correctly for
emailing<o:p></o:p></span></p>
<div style='border:none;border-bottom:solid windowtext 1.0pt;padding:0cm
0cm 1.0pt 0cm'>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
</div>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>This is
the CLI output<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>--
Executing
[4099XXXXXX at port3_real:1] Goto("DAHDI/50-1",
"newhire,s,1")
in<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>new
stack<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> -- Goto
(newhire,s,1)<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> --
Executing [s at newhire:1] Ringing("DAHDI/50-1",
"") in new
stack<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> --
Executing [s at newhire:2] Answer("DAHDI/50-1",
"") in new
stack<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> -- Executing
[s at newhire:3] Monitor("DAHDI/50-1",
"wav,/var/lib/asterisk/soun<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>ds/NewHire/Newhire-1240503071.15148-4099819213-s,o")
in new stack<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> --
Executing [s at newhire:4] AGI("DAHDI/50-1",
"newhire.php") in
new stack<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> --
Launched AGI Script
/var/lib/asterisk/agi-bin/newhire.php<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> --
<DAHDI/50-1>AGI Script newhire.php completed, returning
0<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> -- Auto
fallthrough, channel 'DAHDI/50-1' status is
'UNKNOWN'<o:p></o:p></span></p>
<div style='border:none;border-bottom:solid windowtext 1.0pt;padding:0cm
0cm 1.0pt 0cm'>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> -- Hungup
'DAHDI/50-1'<o:p></o:p></span></p>
</div>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>Here is
the script<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>#!/usr/bin/php5 <o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><?php<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>// Get
AGI vars from *<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> $agivars =
array();<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> while (!feof(STDIN))
{<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>
$agivar = trim(fgets(STDIN));<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> if
($agivar === '') {<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>
break;<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>
}<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>
$agivar = explode(':',
$agivar);<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>
$agivars[$agivar[0]] =
trim($agivar[1]);<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> }<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'> extract($agivars);<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>//
Variable Declarations<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>$agi_uniqueid;<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>$agi_callerid;<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>$agi_calleridname;<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>$agi_extension;<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>$agi_uniqueid;<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>$UNIQUEID
= $agi_uniqueid;<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>$CALLERID
= $agi_callerid;<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>$EXTEN =
$agi_extension;<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>$attachment
"/var/lib/asterisk/sounds/NewHire/Newhire-$UNIQUEID-$CALLERID-$EXTEN.wav";<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>$from
"…@xxx.com";
<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>$to
="jas at answeringserv.com
";<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>$subject="New
Applicant";<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>$headers
= "From:
$from";<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>$message
="$UNIQUEID ,
$CALLERID , $EXTEN ,
$attachment";<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>mail($to,$subject,$message,$headers);<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'>?><o:p></o:p></span></p>
<div style='border:none;border-bottom:solid windowtext 1.0pt;padding:0cm
0cm 1.0pt 0cm'>
<p class=MsoNormal><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
</div>
<p class=MsoNormal><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>So
is it anything obviously wrong with the script I’m
missing?<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier
New"'><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:9.0pt;font-family:"Courier New"'>Besides
something not being configured in php.ini correctly any other
ideas?<o:p></o:p></span></p>
<p class=MsoNormal><span
lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:18.0pt;font-family:"Brush Script MT";
color:#1F497D'>James
Shigley<o:p></o:p></span></p>
<p class=MsoNormal><b><span lang=EN-US
style='font-size:18.0pt;font-family:
"Bradley Hand ITC";color:#1F497D'>Monroe Telephone Answering
Service<o:p></o:p></span></b></p>
<p class=MsoNormal><span
lang=EN-US>409-981-9213</span><b><span lang=EN-US
style='font-size:18.0pt;font-family:"Bradley Hand
ITC";color:#1F497D'><o:p></o:p></span></b></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:8.0pt;font-family:"Arial","sans-serif"'>Infinity
5.5,UC 4.02.3803, Blink 3.0.104<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:8.0pt;font-family:"Arial","sans-serif"'>Ecreator:2.21,
eResponse 1.1.7<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:8.0pt;font-family:"Arial","sans-serif"'>Webportal,WebApps,<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US> </span><span
lang=EN-US
style='font-size:12.0pt;font-family:"Times New
Roman","serif"'><o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>CONFIDENTIALITY NOTICE:
</span><span
lang=EN-US style='font-size:7.5pt'>This email, including any
attachments,
contains information which may be confidential or privileged. The information
is intended to be for the use of the individual or entity named above. If you
are not the intended recipient, be aware that any disclosure, copying,
distribution or use of the contents of this information is prohibited. If you
have received this email in error, please notify the sender immediately by
"reply to sender only" message and destroy all electronic and
hard copies
of the communication, including attachments.</span><span lang=EN-US>
<o:p></o:p></span></p>
<p class=MsoNormal><span
lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:10.5pt;font-family:Consolas'>"Common
sense is the collection of prejudices acquired by age eighteen." --
Albert
Einstein <o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:10.5pt;font-family:Consolas'>"Once
you can accept the universe as matter expanding into nothing that is
something,wearing stripes with plaid comes easy." -- Albert
Einstein<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US
style='font-size:10.5pt;font-family:Consolas'>"I
know a little of everything, but a lot of
nothing"<o:p></o:p></span></p>
<p class=MsoNormal><span
lang=EN-US><o:p> </o:p></span></p>
</div>
</body>
</html>
--Boundary_(ID_K5GCuljoUugxYJE7QmfLGQ)--