[BRLTTY] Appending NUL to cat

Michael Whapples mwhapples at aim.com
Mon Sep 28 18:49:47 EDT 2009


Could the extra characters/text you hear be "e n"? If so it seems your 
copy of echo is not recognising the -e option, but if speech is coming 
out then it must be inserting the NULL. Try editing your script to 
remove the -e option from the echo command, does it help? Having a look 
at various shells on my system it seems some versions of echo will do 
the escape sequences needed to get the NULL character even without 
giving the -e option.

Michael Whapples
On 28/09/09 22:49, james collins wrote:
> The script worked, but my synthesizer says something in the beginning?
> Like it adds, it sounds like "bn" or "vn" to what I write?
>
> Sent from my iPhone
>
> On Sep 28, 2009, at 5:08 PM, Michael Whapples<mwhapples at aim.com>  wrote:
>
>    
>> The first line should start while and end with do
>> second line has an echo command
>> Third line should just be done
>>
>> Hope that makes it clearer as to the lines.
>>
>> As for shells, you probably have bash, so you could replace sh with
>> bash
>> when launching the script or in the #!/bin/sh (so line reads #!/bin/
>> bash
>> ). I am using bash here.
>>
>> Michael Whapples
>> On 28/09/09 21:42, james collins wrote:
>>      
>>> On my phone which is where I am reading this email the lines you gave
>>> gotten broken up into four lines? Just wondering how to enter those
>>> lines:
>>>
>>> while starts the 1st line and it ends w/;
>>> do starts the second line
>>> and done is on the third line?
>>>
>>> Is that right? Also I looked at the man page for echo under bash on
>>> my
>>> computer, there is a -n option but no -e option, I wondered if that
>>> would make a difference? I guess I am using sh though?
>>>
>>> Sent from my iPhone
>>>
>>> On Sep 28, 2009, at 3:26 PM, Michael Whapples<mwhapples at aim.com>
>>> wrote:
>>>
>>>
>>>        
>>>> You are correct that you would put at the beginning of the script
>>>> the line:
>>>> #!/bin/sh
>>>>
>>>> Also how you said to start it is correct (in fact for running it in
>>>> the
>>>> way you describe that #!/bin/sh line wouldn't be needed).
>>>>
>>>> An alternative would be to set the script to be executable, a
>>>> command like:
>>>> chmod a+x your_file_name
>>>>
>>>> will set the file you name in the place of your_file_name to be
>>>> executable by all users. Then you can run it by simply giving the
>>>> file
>>>> name on the command line. However for this to work you MUST remember
>>>> to
>>>> include that #!/bin/sh line otherwise the system won't know what to
>>>> run
>>>> the script with. Also if you use this you can put the script in a
>>>> directory pointed at by $PATH and you can run it using just the
>>>> script's
>>>> name (eg. if you called the script file "speak_lines" and placed it
>>>> in a
>>>> directory in $PATH (on my linux system /usr/local/bin would be a
>>>> good
>>>> choice) then it could be run just giving the speak_lines command).
>>>>
>>>> Now for how this script behaves:
>>>> Precisely how you described you wanted things to work. Launch the
>>>> script
>>>> and the cursor is placed on a new line waiting for you to enter
>>>> text.
>>>> Enter text and press enter, it will append a NULL character to the
>>>> text
>>>> and send it to /dev/cu.usbserial-FTKVMAFF and hopefully the synth
>>>> will
>>>> talk. The cursor will have dropped down a line and be waiting for
>>>> more
>>>> text, keep entering lines of text until you get bored with it, at
>>>> which
>>>> point press ctrl+d on a blank line (ends file, tells the script no
>>>> more
>>>> text to read) or ctrl+c (not so preferred as this kills it) and in
>>>> either case you will find yourself back at the shell prompt.
>>>>
>>>> Michael Whapples
>>>> On 28/09/09 20:09, james collins wrote:
>>>>
>>>>          
>>>>> Thanks for the responses. To make a script out of the lines you
>>>>> gave
>>>>> me, would I write in a text editor, first line:
>>>>> #!/bin/sh
>>>>> How would I invoke this script, like let's say I made a script, and
>>>>> called it samplescript.txt, if I was in the directory where it was
>>>>> located I would say:
>>>>> sh ./samplescript.txt
>>>>> what would happen next? In the script cat never gets called?
>>>>> Would my
>>>>> cursor drop down a line and I would enter text? And when I hit
>>>>> return
>>>>> a NUL character would be appended to the end of the text? And
>>>>> then if
>>>>> I hit cntrl-c it would exit cat?
>>>>>
>>>>> Sent from my iPhone
>>>>>
>>>>> On Sep 28, 2009, at 1:46 PM, Michael Whapples<mwhapples at aim.com>
>>>>> wrote:
>>>>>
>>>>>
>>>>>
>>>>>            
>>>>>> You can do what you are asking for in three lines:
>>>>>>
>>>>>> while read myline ; do
>>>>>> echo -e -n "$myline\00">/dev/cu.usbserial-FTKVMAFF
>>>>>> done
>>>>>>
>>>>>>
>>>>>>              
>>>>> On my phone it is written as four lines?
>>>>>
>>>>>
>>>>>            
>>>>>> For convenience you may want to put those three lines in a text
>>>>>> file
>>>>>> to
>>>>>> make a script.
>>>>>>
>>>>>> Michael Whapples
>>>>>> On 28/09/09 18:06, Dave Mielke wrote:
>>>>>>
>>>>>>
>>>>>>              
>>>>>>> [quoted lines by james collins on 2009/09/28 at 12:29 -0400]
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>>>> Just wondering what I am doing wrong? I want to use cat, but I
>>>>>>>> want to
>>>>>>>> append a NUL character to what I type? I tried typing:
>>>>>>>> echo -e -n '\000' | cat>     /dev/cu.usbserial -FTKVMAFF
>>>>>>>> What I was hoping would happen, is my cursor would drop down a
>>>>>>>> line
>>>>>>>> and I would be in the cat command, I would then right some text
>>>>>>>> and
>>>>>>>> when I hit return, a NUL character would be appended to the
>>>>>>>> text I
>>>>>>>> had
>>>>>>>> written and my synthesizer would speak the words I had written?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                  
>>>>>>> I think you mustn't be very familiar with Unix-style operating
>>>>>>> systems.
>>>>>>>
>>>>>>> When you join two commands with |, what you're doing is
>>>>>>> redirecting
>>>>>>> the input
>>>>>>> of the second command (in your case, cat) away from your keyboard
>>>>>>> and to the
>>>>>>> output of the first command (in your case, echo).
>>>>>>>
>>>>>>> There's no magic way to do what you're wanting to do. If you
>>>>>>> want a
>>>>>>> NUL
>>>>>>> appended to each line you type before that line is written to
>>>>>>> your
>>>>>>> synthesizer
>>>>>>> then you're going to have to write a simple program to do exactly
>>>>>>> that. In this
>>>>>>> case, a fairly simple shell script should suffice.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>> _______________________________________________
>>>>>> This message was sent via the BRLTTY mailing list.
>>>>>> To post a message, send an e-mail to: BRLTTY at mielke.cc
>>>>>> For general information, go to: http://mielke.cc/mailman/listinfo/brltty
>>>>>>
>>>>>>
>>>>>>              
>>>>> _______________________________________________
>>>>> This message was sent via the BRLTTY mailing list.
>>>>> To post a message, send an e-mail to: BRLTTY at mielke.cc
>>>>> For general information, go to: http://mielke.cc/mailman/listinfo/brltty
>>>>>
>>>>>
>>>>>            
>>>> _______________________________________________
>>>> This message was sent via the BRLTTY mailing list.
>>>> To post a message, send an e-mail to: BRLTTY at mielke.cc
>>>> For general information, go to: http://mielke.cc/mailman/listinfo/brltty
>>>>
>>>>          
>>> _______________________________________________
>>> This message was sent via the BRLTTY mailing list.
>>> To post a message, send an e-mail to: BRLTTY at mielke.cc
>>> For general information, go to: http://mielke.cc/mailman/listinfo/brltty
>>>
>>>        
>> _______________________________________________
>> This message was sent via the BRLTTY mailing list.
>> To post a message, send an e-mail to: BRLTTY at mielke.cc
>> For general information, go to: http://mielke.cc/mailman/listinfo/brltty
>>      
> _______________________________________________
> This message was sent via the BRLTTY mailing list.
> To post a message, send an e-mail to: BRLTTY at mielke.cc
> For general information, go to: http://mielke.cc/mailman/listinfo/brltty
>    



More information about the BRLTTY mailing list