How Do You Install the Lua Compiler on a CentOS/RHEL/Fedora Server?

Problem scenario
You want to run Lua programs on your Red Hat derivative distribution of Linux server (e.g., CentOS/RHEL/Fedora).  

Solution
1.  Make a script like this called lua.sh with the following lines:

yum -y install readline-devel gcc
curl https://www.lua.org/ftp/lua-5.3.5.tar.gz > /tmp/lua-5.3.5.tar.gz
mv /tmp/lua-5.3.5.tar.gz /opt/
cd /opt/
tar -xzvf lua-5.3.5.tar.gz
cd lua-5.3.5
sudo make linux test
echo “ENV=$ENV:/opt/lua-5.3.5/src/” >>

How Do You Troubleshoot the Scala Error “No such file or class on class path”?

Problem scenario
You know Scala is installed because you use “man scala” and see the correct man page.  But when you try to find the version, you get an error.  Specifically you run this command:  scala version

You see this: “No such file or class on classpath: version.”  How do you find out what version of Scala you have installed?

Solution
Reboot the server.

How Do You Install Scala on an Ubuntu Instance of AWS?

Problem scenario
You want to install Scala to an Ubuntu instance of AWS.  How do you do this?

Solution

Prerequisite
Verify you have 1 GB of RAM.  Run this command:  sudo dmidecode -t 17 | grep Size

If you see 512 MB in the output, then you will not be able to get Scala installed.  You will need an AWS instance with a flavor that has 1 GB of RAM or more. 

How Do You Install Scala on a RHEL Instance of AWS?

Problem scenario
You want to install Scala to a Red Hat Enterprise Linux instance of AWS.  How do you do this?

Solution
1.  Install Java:  sudo yum -y install java-1.8*

2.  Log off and log back on.

3.  Run these three commands:
curl https://bintray.com/sbt/rpm/rpm | sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo
sudo yum -y install sbt
sbt new scala/hello-world.g8

4. 

Using Bash How Do You Replace a Line in a File by Its Line Number?

Problem scenario
On your Linux server you know one line in a file needs to be replaced.  You can identify the file by its line number.  You have a string or pattern you want to be inserted where this line is. How do you do this with Bash?

Solution
To replace all the content of line 15 of foobar.txt with “Hello World” run this command:

perl -i -pe ‘s/.*/Hello World/ if $.==15’ foobar.txt

For something more advanced,

Perl Script Debugging

Problem scenario:  You are running a Perl program and getting an error “syntax error at cool.pl line x, near …
Global symbol “$foo” requires explicit package name at cool.pl line x…”

Solution:  Find line x – 1, that is, the line before x.  This line may not have a semicolon.  Semicolons are not needed if the Perl script is one line.  Semicolons are not needed for “sub main” declaration lines with a line with just a brace (either “{” or “}”). 

How To Integrate Perl, Ruby, and Python Programs

Problem scenario
You want a Perl program to call a Python program to call a Ruby program to call another Python program.  You are using Linux as the OS.

Solution
Here is a one-line Perl program (course.pl) that calls a Python program:

system( “python /home/ec2-user/cont.py”);

Here is a two-line Python program named cont.py.  It invokes a Ruby program.

import subprocess
subprocess.call([‘ruby /home/ec2-user/integration.rb’],

Moving a Windows .txt file to a Linux Server

Problem scenario:  When you move a Windows .txt file to a Linux server, new characters can be introduced.  For example, the content of the file can have a “^M” (with no quotes) at the end of every line.  Sometimes tr, sed, and awk won’t work to remove this new jibberish (extraneous characters).  Moreover, sometimes the substitute command in vi will fail to do anything about these extraneous characters (^M).  How do you eliminate these extra characters at the end of every line?