Dear All.
I’m trying to play with LCD4Linux
There is fascility from LCD4Linux that let it to read to a file, and
refresh
the LCD with the content of file being read.
For a dirty trial , I use a Curse driver for LCD4Linux display.
It emulate 4 line LCD
I made 4 file , each intended for each line of the LCD
Next , I wrote simple BASH script below :
—START----
#!/bin/sh
a=0
b=0
while true
do
a=$(($a+1))
b=$(($b+1))
f="/mnt/ramdisk0/line"$a
echo $b >$f
if [ “$a” -eq 4 ]
then
a=0
fi
done
----STOP----
Let the script run.
While the script run … I open 2nd console
And from that last console I run lcd4linux … and find that it work
just
like what I want.
LCD4Linux read the file … and display the content perfectly.
Next …
I tried to do it with ruby :
—Start----
irb
irb(main):001:0> my_file = File.new("/mnt/ramdisk0/line3",
modestring=“a+”)
=> #<File:/mnt/ramdisk0/line3>
irb(main):002:0> my_file.flock(File::LOCK_UN)
=> 0
irb(main):003:0>
irb(main):004:0* my_file.puts “write it”
=> nil
----Stop—
The LCD4Linux can not read the file … so it can not display the content
to
LCD.
But, when I try :
irb(main):005:0> exit
And back to my main Shell … LCD4Linux can read the file and display
the
content.
2 Question :
- How to make rubby to do shared file access ?
- the file.puts command always write to the end of the file, How to
make
ruby just overide the content of the file with it’s output ?
(just like bash ==> echo “something” >./thisfile )
Sincerely
-bino-