How Do You Troubleshoot Error Messages in a Bash Script?

Problem scenario
You run a shell or bash script but you receive an error message such as one of the following:

$’\r’: command not found
line:55 syntax error: unexpected end of file

Solution
Did you download the file from the internet directly to the Unix system? The root cause could be that there are invisible characters in the file.

If you can copy the content of the text into the Linux machine and have it run as a script,

 » Read more..

How Do You Troubleshoot the Bash Script Error “line 5: $’\r’: command not found”?

Problem scenario
You drafted a Bash script on a Windows computer.  You then uploaded it to Google Cloud Platform via a web browser feature.  When you run the bash script on a Linux server (e.g., in GCP), you get this error “line 5: $’\r’: command not found”.  You do not want to install dos2unix or any new packages.  What should you do?

Solution
The file needs to be modified or “cleaned up.” 

 » Read more..

How Do You Write a Hello World Program in Lua?

Problem scenario
You want to run a basic Lua program as a test.  What do you do?

Solution
Prerequisite

You must have installed the Lua compiler.  If you are using a CentOS/RHEL/Fedora server, try this link.

Procedures
1.  Create a file called contint.lua with the following line:
print(“This is a Hello World program”)

2.  Run it with this command: 

 » Read more..

How Do You Write a Hello World Program in Golang?

Problem scenario
You want to test out the Golang compiler.  You want to know how to write a basic Go program and run it.  What do you do?

Solution
Prerequisites

You must have the Golang compiler installed.  If you need help, see this posting.

Procedures
1.  Create a file called hw.go with the following five lines:

package main
import “fmt”
func main() {
   

 » Read more..

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/” >>

 » Read more..

How Do You Install Golang on to Any Type of Linux?

Problem scenario
You want to do some coding in the Go programming language.  You want a script to install Golang on any distribution of Linux (e.g., CentOS/Red Hat Enterprise Linux/Fedora, Debian/Ubuntu, or SUSE).  What do you do?

Solution
1.  Create a file in /tmp/ called go.sh with the following content:

version=1.9.5  # Change this version as needed
curl https://storage.googleapis.com/golang/go$version.linux-amd64.tar.gz > /tmp/go$version.linux-amd64.tar.gz
cp /tmp/go$version.linux-amd64.tar.gz /usr/local/go$version.linux-amd64.tar.gz
cd /usr/local/
tar xzvf go$version.linux-amd64.tar.gz
#echo “export PATH=””$””PATH:/usr/local/go/bin” >>

 » Read more..

How Do You Install the Go Programming Language on an Ubuntu Linux Server?

Problem scenario
You want to use the Go programming language.  There are various directions online that involve downloading files and modifying configuration files.  You just want simple directions to install Go to an Ubuntu Linux server.  What do you do?

Solution
Run these two commands:
sudo apt-get -y update
sudo apt -y install golang-go

 » Read more..

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.

 » Read more..

How Do You Install R on an Ubuntu Linux Instance of AWS?

Problem scenario
You are running Ubuntu Linux in AWS.  You want to install R. How do you do this?

Solution
(These directions below were adapted from this link.)

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

If you see 512 MB in the results of the above command,

 » Read more..

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. 

 » Read more..