Recently we’ve installed Asterisk 16.0 to test it out and noticed one nasty thing.
We use asterisk -rx “something” on several occasions for monitoring purposes and it worked fine on 11, 13 versions. On Asterisk 16 it works as well but as soon as we pipe it to anything like grep or even simple wc -l like this asterisk -rx 'pjsip show contacts' | wc -l
it gives you and output of the command but the shell immediately breaks down, the carriage return is not working anymore and you don’t see what you type in console, it is typed but not visible. This problem breaks our scripts and they are not working as expected anymore, i assume because some output written in variable is broken.
We use CentOS Linux release 7.5.1804 (Core).
Did anyone encounter this problem? Is it a bug or there is workaround for this?
It sounds like it has put console (not the shell) into canonical mode.presumably to allow more interactive use. This generally has to be done on standard input, not standard output, so will ignore the redirection. Really it should test whether standard output is a console before doing this. You could try redirecting standard input to null.
Normally you can resolve this by pressing line feed (control-J) typiing “reset” and then typing line feed again. LF, rather CR is the native Unix line separator, and reset is a shell command that attempts to put the terminal back into a sensible mode.
It may be due to Asterisk no longer including it’s own “libedit” library but instead relying on the system one instead. I wonder if it has a bug or problem. What version is it?
./configure --with-pjproject-bundled
make && make install
grep makeopts -e LIBEDIT
The goal is to see what happens when Asterisk 13 does not use the internal libedit. Please post the output from the grep of makeopts, that will confirm that the build uses the expected library.
I installed CentOS 7 in a virtual machine and I’m unable to reproduce this issue. Can you see if you’re able to reproduce the error using:
asterisk -rx 'core show application Exec'|wc -l
The goal of this is to rule out any possible “offensive” output from the pjsip contacts list, ‘core show application Exec’ will print the same thing for both of us.
In addition please let me know about your terminal. Are you running ‘asterisk -rx’ from the physical console or via SSH? If SSH please tell me what you are using to connect to the Asterisk server (SSH from Mac, putty from Windows, gnome-terminal or another from Linux)? Please tell me the value of your $TERM environmental variable in the shell which you used to run ‘asterisk -rx’.
How did you start the Asterisk daemon? If you are using systemd please provide the asterisk.service unit file you used to start it. If initrd then please provide the init script. If you directly started the Asterisk daemon from the terminal please let me know the value of your $TERM environmental variable from the terminal which started the daemon. Also any command-line arguments used to start the daemon.
Let me know if any changes were made to asterisk.conf compared to make samples.
I am able to reproduce this issue. It seems to be related to having console=yes in asterisk.conf. Could you try removing that, instead set nofork=yes? The only difference from doing this is if you start the Asterisk daemon directly from the command-line (without init.d), you will need to run ‘asterisk -c’. When running from init.d this should not make any difference since init.d doesn’t need console enabled.
I’m working on a patch to fix the issue but I wanted to let you know how to work-around this issue with the existing versions.