[asterisk-users] Multiple readfile oddities, newlines etc

Jonathan H lardconcepts at gmail.com
Tue Oct 18 06:41:14 CDT 2016


I'm going to go ahead and file a bug report, 'cos something definitely
ain't right here! Bug filed:
https://issues.asterisk.org/jira/browse/ASTERISK-26481

This bit of dialplan.....

exten => 5,1,Verbose(Context: ${CONTEXT} Exten:${EXTEN})
    same => n,Set(featurefile=/home/test/feature-1.txt)
    same => n,set(myList=1,12,123,1234,12345,123456,A,AB,ABC,ABCD,ABCDE,ABC123)
    same => n,While($["${SET(rawVar=${SHIFT(myList)})}" != ""])
    same => n,SET(FILE(${featurefile})=${rawVar})
    same => n,SET(fileVar=${FILE(${featurefile},0,1,l,u)})
    same => n,SET(hexDump=${SHELL(hd ${featurefile})})
    same => n,Verbose(Before file: ---${rawVar}--- len ${LEN(rawVar)}
after file: ---${fileVar}--- len ${LEN(fileVar)} hexdump:${hexDump})
    same => n,EndWhile()
    same => n,Hangup()


...produces this output: (tidied only for posting) - this is messed up
in so many ways.

LEN is showing the wrong length.
1 character gets a weird character added.
23, and 4  characters OK
5 characters loses a character - BUT LOOK! Even though hexdump prints
the correct contents and length, have a close look at this: 35|12345|
whereas normally it would have a space before the pipe.
6 characters is OK

Before file: ---1--- len 6 after file: ---1▒--- len 7 hexdump:00000000
 31|1| 00000001
Before file: ---12--- len 6 after file: ---12--- len 7
hexdump:00000000  31 32 |12| 00000002
Before file: ---123--- len 6 after file: ---123--- len 7
hexdump:00000000  31 32 33  |123| 00000003

[Oct 18 12:23:53] ERROR[8584][C-0000001a]: json.c:704 ast_json_vpack:
Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
[Oct 18 12:23:53] ERROR[8584][C-0000001a]: stasis_channels.c:773
ast_channel_publish_varset: Error creating message

Before file: ---1234--- len 6 after file: ---1234--- len 7
hexdump:00000000  31 32 33 34   |1234| 00000004
Before file: ---12345--- len 6 after file: ---1234--- len 7
hexdump:00000000  31 32 33 34 35|12345| 00000005
Before file: ---123456--- len 6 after file: ---123456--- len 7
hexdump:00000000  31 32 33 34 35 36 |123456| 00000006

[Oct 18 12:23:53] ERROR[8584][C-0000001a]: json.c:704 ast_json_vpack:
Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
[Oct 18 12:23:53] ERROR[8584][C-0000001a]: stasis_channels.c:773
ast_channel_publish_varset: Error creating message

Before file: ---A--- len 6 after file: ---A▒--- len 7 hexdump:00000000
 41|A| 00000001
Before file: ---AB--- len 6 after file: ---AB--- len 7
hexdump:00000000  41 42 |AB| 00000002
Before file: ---ABC--- len 6 after file: ---ABC--- len 7
hexdump:00000000  41 42 43  |ABC| 00000003

[Oct 18 12:23:53] ERROR[8584][C-0000001a]: json.c:704 ast_json_vpack:
Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
[Oct 18 12:23:53] ERROR[8584][C-0000001a]: stasis_channels.c:773
ast_channel_publish_varset: Error creating message

Before file: ---ABCD--- len 6 after file: ---ABCD--- len 7
hexdump:00000000  41 42 43 44   |ABCD| 00000004
Before file: ---ABCDE--- len 6 after file: ---ABCD--- len 7
hexdump:00000000  41 42 43 44 45|ABCDE| 00000005
Before file: ---ABC123--- len 6 after file: ---ABC123--- len 7
hexdump:00000000  41 42 43 31 32 33 |ABC123|

On 17 October 2016 at 23:12, Pete Mundy <pete at fiberphone.co.nz> wrote:
> On 18/10/2016, at 10:38 am, Steve Edwards <asterisk.org at sedwards.com> wrote:
>
> cat /home/test/feature-1.txt | hexdump
>
>
> Or just:
>
> hexdump /home/test/feature-1.txt
>
>
> Heh.. yes, fair call ;)
>
> Pete
>
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
>       http://www.asterisk.org/community/astricon-user-conference
>
> New to Asterisk? Start here:
>       https://wiki.asterisk.org/wiki/display/AST/Getting+Started
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users



More information about the asterisk-users mailing list