[Asterisk-Dev] asterisk -r comm issues
John Todd
jtodd at loligo.com
Tue Dec 2 20:26:36 MST 2003
> I'm seeing some issues when talking to asterisk
>with 'asterisk -r'
>
> Executing a command like:
>
># asterisk -r -x "sip show peers"
>
>cuts of part of the name/username at the beginning of the line,
>truncates the list, or only prints the Name/Username header.
>
> Anyone else seen this? Any ideas for how to fix this?
>
> - Jared
>
>--
>Jared Mauch | pgp key available via finger from jared at puck.nether.net
>clue++; | http://puck.nether.net/~jared/ My statements are only mine.
Good timing. I think this fix will cure what ails you.
JT
>Date: Tue, 2 Dec 2003 20:32:51 -0600
>To: bugs at digium.com
>Subject: [Applications 0000183]: [patch] asterisk -rx "database
>show" produces short results
>From: bugs at digium.com
>
>
>The following bug has been RESOLVED.
>======================================================================
>http://bugs.digium.com/bug_view_page.php?bug_id=0000183
>======================================================================
>Reporter: jtodd
>Handler: bkw918
>======================================================================
>Project: Applications
>Bug ID: 183
>Category: General
>Reproducibility: always
>Severity: minor
>Priority: normal
>Status: resolved
>Resolution: fixed
>======================================================================
>Date Submitted: 08-27-2003 00:41 CDT
>Last Modified: 12-02-2003 20:41 CST
>======================================================================
>Summary: [patch] asterisk -rx "database show"
>produces short results
>Description:
>Running a "database show" command from the command line execution syntax
>results in only partial results of what is in the database.
>======================================================================
>
>----------------------------------------------------------------------
> markster - 08-28-2003 11:29 CDT
>----------------------------------------------------------------------
>If the data is not read off the socket sufficiently quickly, then Asterisk
>will simply cut the writing short rather than stall the server. I could
>experiment with a slight delay but that could potentially introduce
>problems.
>
>----------------------------------------------------------------------
> jtodd - 08-28-2003 12:58 CDT
>----------------------------------------------------------------------
>I understand why the unexpected behavior is happening, but I also need to
>be able to get data out of the database on simple shell scripts. I don't
>know of anything faster than simple redirects from a shell, so some sort of
>padding or delay at the end of each line might be required.
>
>I'm open to any other way to access the data in the astdb from a shell
>script run out of cron without corrupting astdb.
>
>----------------------------------------------------------------------
> jamesgolovich - 08-28-2003 13:09 CDT
>----------------------------------------------------------------------
>I've experienced the same problem in the past and when I was working on the
>code I could not find an acceptable way to handle it without causing worse
>problems.
>
>As an alternative, I know that using the Command action from the manager
>interface does not experience this problem.
>
>----------------------------------------------------------------------
> martinp - 09-11-2003 15:42 CDT
>----------------------------------------------------------------------
>Try to set 'hostname box' eg: less letters than 'localhost'. It's a bug
>related to the fact that in asterisk -r mode after you hit 'enter' the
>library first prints the CLI prompt and then prints the command output.
>However in the -c mode it's not done. I've been tracing it but can't find
>the source.
>
>----------------------------------------------------------------------
> jtodd - 09-11-2003 16:48 CDT
>----------------------------------------------------------------------
>Yes, changing the name to something short (like "box") does solve the
>symptoms.
>
>----------------------------------------------------------------------
> jtodd - 09-11-2003 16:50 CDT
>----------------------------------------------------------------------
>OK, I spoke too soon. It appears to solve it on the CLI, but asterisk -rx
>"database show" still fails with random length output, even with the short
>hostname.
>
>----------------------------------------------------------------------
> mic - 09-19-2003 10:26 CDT
>----------------------------------------------------------------------
>I have noticed that almost all
>asterisk -rx "a command"
>produce, some times, short results.
>I have solved (?) the problem
>with the following patch.
>Minor side effect: It prints two extra
>new lines after command completion
>to signal the end of command output.
>
>RCS file: /usr/cvsroot/asterisk/asterisk.c,v
>retrieving revision 1.22
>diff -r1.22 asterisk.c
>780c780
>< if ((buf[res-1] == '\n') || (buf[res-2] == '\n'))
>{
>---
>> if ((buf[res-1] == '\n') && (buf[res-2] == '\n'))
>{
>
>RCS file: /usr/cvsroot/asterisk/cli.c,v
>retrieving revision 1.9
>diff -r1.9 cli.c
>1010a1011
>> ast_cli(fd, "\n\n");
>
>----------------------------------------------------------------------
> jtodd - 09-19-2003 14:54 CDT
>----------------------------------------------------------------------
>Mic - this does in fact seem to solve the problem, sort-of. I was able to
>get a good output when running:
>
>asterisk -rx "database show"
>
>But, when I tried this command:
>
>asterisk -rx "datbase show" >/tmp/foo
>
>...the process seemed to hang and I had to ctrl-c to exit. The data file
>had the content I expected, but for some reason the command just didn't
>seem to end correctly. Can you please take a look at that and see what you
>can do? Otherwise, this seems to be a good patch.
>
>Also: In the future, can you please use "diff -u" and attach your patches
>as files instead of in the notes? This makes it easier to track revisions
>and for the files to be moved around/managed.
>
>----------------------------------------------------------------------
> mic - 09-20-2003 05:49 CDT
>----------------------------------------------------------------------
>John,
>I 'll try it with commands that generate more output
>and see what I can do. May be Mark could advice if
>this is the right place (in asterisk.c, cli.c) to look
>for this problem.
>
>Sorry for the inline patch. I guess it was too small to
>redirect it into a file and attach it.
>
>----------------------------------------------------------------------
> mic - 09-24-2003 13:55 CDT
>----------------------------------------------------------------------
>The uploaded file (netconsole.patch) is the previously sent patch
>but with a timeout inside the select (waiting
>for activity on the fds). There are situations
>where the command has executed but the connection remains
>open (don't know why). I believe that the timeout
>in select should exist, even without this problem,
>just to ensure that the connection will be terminated
>after a certain amount of inactivity.
>
>----------------------------------------------------------------------
> bkw918 - 12-02-2003 20:41 CST
>----------------------------------------------------------------------
>Fixed in CVS
>
>Bug History
>Date Modified Username Field
>Change
>======================================================================
>08-27-03 00:41 jtodd New
>Bug
>08-28-03 11:19 markster Assigned To =>
>markster
>08-28-03 11:19 markster Status new =>
>assigned
>08-28-03 11:29 markster Bugnote Added:
>0000658
>08-28-03 12:58 jtodd Bugnote Added:
>0000661
>08-28-03 13:09 jamesgolovich Bugnote Added:
>0000662
>09-11-03 15:42 martinp Bugnote Added:
>0000922
>09-11-03 16:48 jtodd Bugnote Added:
>0000924
>09-11-03 16:50 jtodd Bugnote Added:
>0000925
>09-19-03 10:26 mic Bugnote Added:
>0001090
>09-19-03 10:28 mic Bug Monitored:
>mic
>09-19-03 14:54 jtodd Bugnote Added:
>0001096
>09-20-03 05:49 mic Bugnote Added:
>0001101
>09-24-03 13:49 mic File Added:
>netconsole.patch
>09-24-03 13:55 mic Bugnote Added:
>0001146
>09-29-03 02:45 jtodd summary asterisk
>-rx "database show" produces short results => [patch] asterisk -rx
>"database show" produces short results
>11-05-03 17:50 jpiterak Bug Monitored:
>jpiterak
>12-02-03 20:41 bkw918 Bugnote Added:
>0002643
>12-02-03 20:41 bkw918 Assigned To markster
>=> bkw918
>12-02-03 20:41 bkw918 Resolution open =>
>fixed
>12-02-03 20:41 bkw918 Status assigned
>=> resolved
>======================================================================
More information about the asterisk-dev
mailing list