Summary: | ASTERISK-05690: ASTCC AGI get_variable can not get? | ||
Reporter: | yippee (yippee) | Labels: | |
Date Opened: | 2005-11-23 21:25:53.000-0600 | Date Closed: | 2011-06-07 14:10:50 |
Priority: | Minor | Regression? | No |
Status: | Closed/Complete | Components: | Core/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ||
Description: | $res = $AGI->exec("DIAL $dialstr"); $dialstatus = $AGI->get_variable("DIALSTATUS"); printf(":::::%d::::%s::::\n",$dialstatus,$dialstatus); $answeredtime = $AGI->get_variable("ANSWEREDTIME"); print "----$answeredtime---\n"; debug info: AGI Tx >> 200 result=-1 AGI Rx << GET VARIABLE DIALSTATUS AGI Tx >> 200 result=1 (ANSWER) AGI GET!! AGI Rx << :::::0:::::::: DEBUG ERROR!! AGI Tx >> 510 Invalid or unknown command AGI Rx << GET VARIABLE ANSWEREDTIME AGI Tx >> 200 result=1 (20) AGI DET!! AGI Rx << ----ANSWER--- DEBUG PRE RESULT? AGI Tx >> 510 Invalid or unknown command I have find the 0003725 ,he said It put the line "#!/usr/bin/php -q" on my AGI files, and Asterisk considered them as AGI commands. but my agi : #!/usr/bin/perl ****** ADDITIONAL INFORMATION ****** $dialstatus = $AGI->get_variable("DIALSTATUS"); printf("::-%d-:::-%d-::::-%s-::::\n",$res,$dialstatus,$dialstatus); $dialstatus = $AGI->get_variable("DIALSTATUS"); printf("::-%d-:::-%d-::::-%s-::::\n",$res,$dialstatus,$dialstatus); $answeredtime = $AGI->get_variable("ANSWEREDTIME"); print "----$answeredtime---\n"; $answeredtime = $AGI->get_variable("ANSWEREDTIME"); print "----$answeredtime---\n"; $answeredtime = $AGI->get_variable("ANSWEREDTIME"); print "----$answeredtime---\n"; $answeredtime = $AGI->get_variable("ANSWEREDTIME"); print "----$answeredtime---\n"; AGI Rx << GET VARIABLE DIALSTATUS AGI Tx >> 200 result=1 (ANSWER) AGI Rx << ::-0-:::-0-::::--:::: AGI Tx >> 510 Invalid or unknown command AGI Rx << GET VARIABLE DIALSTATUS AGI Tx >> 200 result=1 (ANSWER) AGI Rx << ::-0-:::-0-::::-ANSWER-:::: AGI Tx >> 510 Invalid or unknown command AGI Rx << GET VARIABLE ANSWEREDTIME AGI Tx >> 200 result=1 (3) AGI Rx << ------- AGI Tx >> 510 Invalid or unknown command AGI Rx << GET VARIABLE ANSWEREDTIME AGI Tx >> 200 result=1 (3) AGI Rx << ----ANSWER--- AGI Tx >> 510 Invalid or unknown command AGI Rx << GET VARIABLE ANSWEREDTIME AGI Tx >> 200 result=1 (3) AGI Rx << ------- AGI Tx >> 510 Invalid or unknown command AGI Rx << GET VARIABLE ANSWEREDTIME AGI Tx >> 200 result=1 (3) AGI Rx << ----3--- | ||
Comments: | By: twisted (twisted) 2005-11-23 23:00:24.000-0600 the problem is that asterisk runs the agi, and therefore is the reciever of stdout, which printf() writes to in this instance. Did you add the printf()'s or are they in there already? Basically they just need to be removed. By: yippee (yippee) 2005-11-23 23:17:58.000-0600 because I can not get perl agi source-code,so I use PHP agi. like perl-astcc $res = $agi->exec("DIAL SIP/123/5508|30|HL(17982600000:60000:30000)"); $dialstatus = $agi->get_variable("DIALSTATUS"); print("#######\n"); print("--".$dialstatus); print "\n"; print("**********\n"); sleep(1); $answeredtime = $agi->get_variable("ANSWEREDTIME"); print("#######\n"); print "--".$answeredtime; print "\n"; print("*********\n"); it output: AGI Tx >> 200 result=-1 AGI Rx << GET VARIABLE DIALSTATUS AGI Tx >> 200 result=1 (ANSWER) AGI Rx << ####### AGI Tx >> 510 Invalid or unknown command AGI Rx << --200 result=-1 AGI Tx >> 510 Invalid or unknown command AGI Rx << ********** AGI Tx >> 510 Invalid or unknown command AGI Rx << GET VARIABLE ANSWEREDTIME AGI Tx >> 200 result=1 (6) AGI Rx << ####### AGI Tx >> 510 Invalid or unknown command AGI Rx << --200 result=1 (ANSWER) AGI Tx >> 510 Invalid or unknown command AGI Rx << ********* AGI Tx >> 510 Invalid or unknown command AGI Rx << HANGUP AGI Tx >> 200 result=1 the phpagi.php do { $str =trim(fgets($this->in, 4096)); } while($str == '' && $count++ < 5); I think it read in only one time, I modify it : do { $str =trim(fgets($this->in, 4096)); $ri=strstr($str,"result"); } while($ri ==false && $count++ < 5); AGI Tx >> 200 result=-1 AGI Rx << GET VARIABLE DIALSTATUS AGI Tx >> 200 result=1 (ANSWER) AGI Rx << ####### AGI Tx >> 510 Invalid or unknown command AGI Rx << --200 result=1 (ANSWER) AGI Tx >> 510 Invalid or unknown command AGI Rx << ********** AGI Tx >> 510 Invalid or unknown command AGI Rx << GET VARIABLE ANSWEREDTIME AGI Tx >> 200 result=1 (7) AGI Rx << ####### AGI Tx >> 510 Invalid or unknown command AGI Rx << --200 result=1 (7) AGI Tx >> 510 Invalid or unknown command it seem output ok,but it can not hangup By: twisted (twisted) 2005-11-23 23:25:43.000-0600 that had nothing to do with my question. Did you add the printf()'s or were they there already? By: yippee (yippee) 2005-11-23 23:33:37.000-0600 yes,I debug it and add the printf()'s By: twisted (twisted) 2005-11-23 23:53:37.000-0600 remove the printf()'s. these write to stdout, and when dealing with the AGI, asterisk is stdout and provides stdin to the application/script that is executed. if you remove your debug statements, more than likely it will work properly. if you want to give debug output, do something like VERBOSE, which will print to the cli. By: yippee (yippee) 2005-11-24 00:30:52.000-0600 oh,not add the printf to cause this error.I find this error and add printf debug it. astcc can not add cdr,so I find when it run => $res = &trytrunk($trunk, $phoneno, $maxmins); and can not run into => elsif ($res eq "ANSWER") { so I debug $res = $AGI->exec("DIAL $dialstr"); $dialstatus = $AGI->get_variable("DIALSTATUS"); and find it do not output my want. I do not think it about printf . I debug it use php,and guess $str =trim(fgets($this->in, 4096)); By: Kevin P. Fleming (kpfleming) 2005-12-12 20:37:23.000-0600 This is apparently a programming/coding issue, not a bug in Asterisk. Please ask for help on the asterisk-users mailing list to see if someone can help you to write your AGI script properly. |