Carlos Garcia Mujica
2007-Oct-29 21:00 UTC
[Telegraph-users] Possible Bug when parsing cli_command
Hello Guys,
I posted a problem about the cli_command, I need my application to call the
"show channels" command, so I started to lookup in the code of
telegraph the
possible places where the problem might be.
I got to the place where the CLI_COMMANDS are parsed, in the ami_server.rb.
The problem is that the CLI_COMMANDS are not executed because there is a
condition that isn''t working.
#For cli_command - unformated response
if $1 == ''Follows''
at line 668 approx.
I suspect it''s happening because in line 659 approx. there is a
condition:
elsif line =~ /^Response:\s(.*)#{CRLF}/ || line =~ /^ActionID:\s(.*)#{CRLF}/
this condition is fine, but after that the line is overwritten in the
condition:
if line =~ /^ActionID:\s(.*)#{CRLF}/
that''s why $1 is nil and if $1 == ''Follows'' is giving
me false, being unable
to process the information that Asterisk is sending.
I solved my problem modifying the second conditional, it looks like:
if line !~ /^Response:\s(.*)#{CRLF}/ && line =~
/^ActionID:\s(.*)#{CRLF}/ instead of
if line =~ /^ActionID:\s(.*)#{CRLF}/
then $1 is not overwritten when it shouldn''t and the cli_command works
just
fine.
If anyone has another idea or doesn''t have this problem doing
cli_command("help") please post.
Best Regards,
Carlos
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/telegraph-users/attachments/20071029/0d737a18/attachment.html