# string= break up string to fill all four lines in the correct order # usr/bin/lcd_out_4x20 is on the USB stick #!/bin/sh LCDOUT=/usr/bin/lcd_out_4x20 #stringZ="test output" # will come from web page via LCDsend.cgi lineone=`expr substr "$stringZ" 1 20` linetwo=`expr substr "$stringZ" 21 20` linethree=`expr substr "$stringZ" 41 20` linefour=`expr substr "$stringZ" 61 20` echo '' echo 'on the LCD screen
' echo 'your message will look like this -

' echo '
' echo '' echo $lineone echo '
' echo $linetwo echo '
' echo $linethree echo '
' echo $linefour echo '

' echo '' echo 'on the Sweex LCD display' echo '
' #initiallise the display $LCDOUT -i usleep 60000 #do it again - bug in driver? $LCDOUT -i usleep 60000 #send the firstline - this will never be empty $LCDOUT `expr substr "$stringZ" 1 20` usleep 60000 #create the next lines and stop when line is empty line=2 while true; do offset=`expr '(' $line - 1 ')' '*' 20 + 1` str=`expr substr "$stringZ" $offset 20` if [ "$str" = "" ]; then break; fi #(do not send empty lines) #say which line to fill $LCDOUT -$line usleep 60000 #send the string to fill it $LCDOUT $str usleep 60000 line=`expr $line + 1` done #thanks to my anonymous helper for the last bit!