By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,933 Members | 1,676 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,933 IT Pros & Developers. It's quick & easy.

how to write vxml in perl?

P: 2
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. # PERL MODULES WE WILL BE USING
  3. use DBI;
  4. use DBD::mysql;
  5.  
  6. use Asterisk::AGI;
  7. $AGI = new Asterisk::AGI;
  8.  
  9. # HTTP HEADER
  10.  
  11. # Print "Content-type:text/vxml \n\n";
  12.  
  13. #CONFIG VARIABLES
  14. $platform="mysql";
  15. $database="employeedet";
  16. $host="localhost";
  17. $port="3306";
  18. $tablename="employee";
  19. $user="";
  20. $pw="";
  21.  
  22. #DATA SOURCE NAME
  23. $dsn="dbi:mysql:$database:localhost:3306";
  24.  
  25. #PERL DBI CONNECT(RENAMED HANDLE)
  26. $dbstore = DBI->connect($dsn,$user,$pw);
  27.  
  28. #PREPARE THE QUERY
  29. $stmtA = "select * from employee where id='1';";
  30. $sthA = $dbstore->prepare($stmtA) or die "preparing:", $dbstore ->errstr;
  31. $sthA->execute or die "SQLERROR:$stmtA".$DBI->errstr;
  32. while(@row = $sthA->fetchrow_array())
  33. {
  34.  $count=$row[1];
  35. }
  36. print qq*
  37. <?xml version="1.0"?>
  38. <vxml>
  39. <form>
  40. <prompt>
  41. The employee name is "$count".
  42. </prmopt>
  43. </form>
  44. </vxml>
  45. *;
  46.  
can any one help me i am getting the output when i type in terminal ./employee.agi

this is my vxml file:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
  3. <form id="employeeid">
  4. <field name="emp" type="number">
  5. <prompt>
  6. Enter your Employee ID
  7. </prompt>
  8. <grammar src="employeeinfo.vxml" type="application/srgs+xml"/>
  9. <filled>
  10. YOu have entered<value expr="emp"/>as employee id number
  11. </filled>
  12. </field>
  13. <block>
  14. <submit next="http://localhost/vxml/test/employee.agi" namelist="emp"/>
  15. </block>
  16. </form>
  17. </vxml>
i have kept employee.agi in /var/www/vxml/test folder


but when i call from a vxml file i am getting error:
Expand|Select|Wrap|Line Numbers
  1. Apr 19 13:23:13.21|-2028012656|94|CRITICAL|com.speechworks.vxi|205|VXIinterpreterRun: Failed to parse the URI's content. Make sure that this document consists of valid VXML.|URL=http://localhost/vxml/test/employee.agi
  2. Apr 19 13:23:13.21|-2028012656|94|EVENT|2|content=Error:  error.badfetch ,  http://localhost/vxml/test/employee.agi
  3.  
please help me its urgent
Apr 19 '09 #1
Share this Question
Share on Google+
3 Replies


Icecrack
Expert 100+
P: 174
Try this i have take out your user and pass for SQL reinsert them

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. # PERL MODULES WE WILL BE USING
  3. use DBI;
  4. use DBD::mysql;
  5.  
  6. use Asterisk::AGI;
  7. $AGI = new Asterisk::AGI;
  8.  
  9. # HTTP HEADER
  10.  
  11. Print "Content-type:text/vxml \n\n";
  12.  
  13. #CONFIG VARIABLES
  14. $platform="mysql";
  15. $database="employeedet";
  16. $host="localhost";
  17. $port="3306";
  18. $tablename="employee";
  19. $user="";
  20. $pw="";
  21.  
  22. #DATA SOURCE NAME
  23. $dsn="dbi:mysql:$database:localhost:3306";
  24.  
  25. #PERL DBI CONNECT(RENAMED HANDLE)
  26. $dbstore = DBI->connect($dsn,$user,$pw);
  27.  
  28. #PREPARE THE QUERY
  29. $stmtA = "select * from employee where id='1';";
  30. $sthA = $dbstore->prepare($stmtA) or die "preparing:", $dbstore ->errstr;
  31. $sthA->execute or die "SQLERROR:$stmtA".$DBI->errstr;
  32. while(@row = $sthA->fetchrow_array())
  33. {
  34. $count=$row[1];
  35. }
  36. print <<XMLPRINT;
  37. <?xml version="1.0"?>
  38. <vxml>
  39. <form>
  40. <prompt>
  41. The employee name is "$count".
  42. </prmopt>
  43. </form>
  44. </vxml>
  45.  
  46. XMLPRINT
  47.  
  48.  
  49.  
  50.  
Apr 21 '09 #2

P: 2
Hi,
I have made the changes near print <<XMLPRINT; but i am getting error as:

Can't find string terminator "XMLPRINT" anywhere before EOF at ./employee.agi line 36.
Apr 21 '09 #3

Icecrack
Expert 100+
P: 174
Make Sure you have a blank line no spaces Before and After XMLPRINT
Apr 22 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.