For the next part of my ESP8266 experiments, I’m going to need LUA running on my RPI, so I want to document the process.
I first stumbled across LUA last fall when I was playing with CHDK – it is one of the scripting languages available to control canon cameras using CHDK. So far, I kind of like it. I detest Perl and just have never really got into Python either. LUA is really what I expect from a scripting language. A clean, simple, easy way to do quick and dirty stuff which doesn’t warrant spending time writing a real program.
The fact LUA’s basic syntax takes only 5 pages of the manual is a bonus. It’s easy enough I might actually remember the syntax between projects.
Turns out, LUA was already installed on my Raspberry Pi. I easily verified this by just typing lua:
rpi/~:lua Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio >
You can also check with whereis:
rpi/~:whereis lua lua: /usr/bin/lua5.1 /usr/bin/lua /usr/bin/X11/lua5.1 /usr/bin/X11/lua /usr/share/lua /usr/share/man/man1/lua.1.gz rpi/~:
If it isn’t installed, install it with:
sudo apt-get update sudo apt-get install lua5.1
I notice there is a lua5.2 available as well. I know what I’m trying to do works with 5.1 so that is the version I am choosing.
I also need the networking module. That is installed with:
sudo apt-get install lua-socket
Other lua modules you may have interest in can be found with this command:
apt-cache search '^lua-.*'
Now create a simple test program such as this helloworld:
rpi/lua:vi helloworld #!/usr/bin/lua print ('hello world')
Make it executable:
rpi/lua:chmod 755 helloworld
and finally try it out:
rpi/lua:./helloworld hello world rpi/lua:
Now I’m ready to write some networking code in LUA on my RPI.