How Do You Create an Option to Logout for a PHP Web Page to Destroy the Session?

Problem scenario
You have a LAMP (or LAPP) web page application.  The PHP code uses the session() functionality.  Once a user logs in successfully, he/she can browse to successive web pages.  You want to at least allow the user the opportunity to destroy the session (and terminate the authentication session).  How do you do this?

Solution
#1  Modify the .php file that you want to have the logout feature.  In the <html> <body> section of your .php file, add this line:

<a href="logout.php">Logout</a>

#2  Create a file named logout.php in the same directory as the .php file referred to in step #1.  Have this be the content of the logout.php file:

session_start();
session_destroy();
echo 'You have been logged out.;<a href="/path/to/login.php">Log in again.<a/>';
exit;

Note that /path/to/ is a subdirectory path of /var/www/html/ (or the default location of the web files).  login.php is the name of the .php file in /var/www/html/path/to/ that allows for logins.

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 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, then you will not be able to get R installed.  You will need a different AWS server -- a flavor with at least 1 GB of RAM.  To upgrade the flavor to have more memory, see this posting.  To add virtual memory (aka swap space), see this posting.

Method
1.  Run these four commands:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
sudo apt-get update
sudo apt-get -y install r-base

2.  a.  Run this command to enter the R command prompt:  sudo -i R 

2. b.  Note that the ">" sign below is just a reference. Do not type the ">" or space thereafter when you type the command below.

install.packages('txtplot')

2. c.    Enter a selection (e.g., 45 if you are in Texas).  Press enter.

2. d.  Run this command from the > prompt.

library('txtplot')

If there were no errors, then it is working.

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.  To upgrade the flavor to have more memory, see this posting.  To add virtual memory (aka swap space), see this posting.

Method
1.  Run these eight commands (including the long one in the middle that is not in bold):

sudo apt-get update
sudo apt-get -y install openjdk-8-jdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk

echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823

sudo apt-get update
sudo apt-get -y install sbt
sudo apt -y install scala

2.  Test if it worked (optional step):
sbt new scala/hello-world.g8

3.  You may want to reboot or export a classpath variable.  This is an optional step.  Once you do this, you can run this command:  scala version

How Do You Log into a Linux Server in Google Cloud Platform?

Problem scenario
You created a Linux VM in GCP.  How do you get credentials to connect to it?  What do you have to do to log in with PuTTY?

Solution
1.  Make sure the firewalls allow for the connection.  See this posting if you need to change that.
2.  In the GCP console, go to Computer Engine -> VM Instances.  
3.  Go to the VM you want to connect to.  Under the "Connect" column find the small triangle that points downward.  Click on it and go to "Open in browser window." Make sure that either your web browser allows pop-ups or that you know how to view the blocked pop-ups manually. In the new tab there will be a pop up prompt, click "Connect".
4.  In the command prompt that appears, type this: sudo su -
5.a.  You may want to create users (e.g., useradd jdoe; passwd jdoe).  You may want to set the password for the user (e.g., passwd initialuser # where "initialuser" is the user you first logged in as).
5.b. You may want to add the new user to the sudoers file. To do this, run this command:
usermod -aG sudo cooluser
6.  Modify the /etc/ssh/sshd_config file.  Make sure that the
"PasswordAuthentication" and "ChallengeResponseAuthentication" stanzas are uncommented out and set to yes.
6.b. If you want to see the history of the commands at the terminal with the "Up" arrow, please see this posting.
7.  Restart sshd.  One way would be to reboot. For a RedHat derivative enter this command as root /etc/init.d/ssh restart. Another way to restart sshd would be to use this: sudo service sshd restart
8.  Now you can use Putty to the external IP address of the Linux VM.  You should be able to log in with username/password combinations in step #5.

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

Problem scenario
You have a RedHat Enterprise version of Linux.  You want to install the R programming language.  What do you do?

Solution
1.  Run these six commands:

sudo yum -y install wget
cd /tmp
wget ftp://rpmfind.net/linux/epel/7/x86_64/e/epel-release-7-10.noarch.rpm
sudo rpm -ivh epel-release-7-10.noarch.rpm
sudo yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
sudo yum -y install R

2.  This is an optional step to complete these instructions.  Use "man R" (type this command with no quotes) to verify it was installed correctly.

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.  Verify Scala has been installed with this command:  scala about

How Do You Troubleshoot the Java Error “java.lang.Error: Properties init: Could not determine current working directory”?

Problem scenario
You run this command:
javac -version

But you receive this error:  "Error occurred during initialization of VM java.lang.Error: Properties init: Could not determine current working directory."

How do you solve this problem?

Solution
Log out of Linux and log back in.

How Do You Know If Apache Spark Has Been Installed?

Problem scenario
You are looking for the Hadoop components' versions.  You run these commands:

hadoop version
hdfs version
yarn version

You notice the output is the same for each of the three commands above.  You are not sure if Apache Spark has been installed.  What do you do?

Solution
Run this command:

spark-submit --version

How Do You Automate a Sequence of GUI Operations to Use Sikulix as a Proof-of-Concept?

Problem scenario
You want to try Sikulix to test it.  What do you do to implement a prototype of GUI automation of a basic procedure?

Solution
Prerequisite #1

This assumes that Sikulix has been installed.  If you do not know how, see this posting.

Prerequisite #2 (specific to this example only)
For this example we will set up an automation to open a web browser, go to the http://rpaforum.net website and log in.  For this example, you will need credentials to log into the http://rpaforum.net.

For this example cookies cannot be blocked from http://rpaforum.net.  If you are using the typical, recommended settings of I.E., do the following:

     1.  Open I.E.  If you are prompted, you may want to accept the recommended settings.

     2.  Go to the gear icon in the upper righthand corner.  Go to "Internet Options."

     3.  Go to Security tab and then click on "Trusted Sites."

     4.  Click on the "Sites" button.

     5.  Enter this text with no quotes "rpaforum.net" and click "Add".  

     6.  Enter this text with no quotes "https://ajax.googleapis.com" and click "Add".

     7.  Enter this text with no quotes "https://www.google-analytics.com" and click "Add".

(There are different ways of eliminating pop-ups for web UI automation purposes.  Adding the above three URLs as Trusted Sites allows you use maintain I.E.'s recommended security settings.)

Warning
This does not encrypt a saved password. This is acceptable as a proof-of-concept.  It is not advisable if the password used in this example is sensitive.

Procedures
1.  Log into the Windows server with Sikulix.  Right click the desktop.  Go to New -> Shortcut.

2.  Insert this text (with no quotes):  "http://rpaforum.net"

3.  Click Next.  

4.  Use the name "RPAForum" (with no quotes) and click "Finish".

5.  Open Sikulix.  Normally you would double click the file named "Sikulix" that is an "Executable JAR File."  If you need assistance, read the following:

If Java was already installed or you rebooted since installing it, there will be a file called "sikulix" that is of the file type "Executable Jar File" in C:\Sikulix.   Right click the file named Sikulix in the C:\Sikulix\ folder.  Go to Create Shortcut -> on Desktop.  This will start the Sikulix program.

If you installed Java without rebooting it since, click the "runsikulix" Windows Command Script in the C:\Sikulix\ folder.  This will start the Sikulix program.

6.  In the Sikulix GUI (aka the IDE), there should be a new, untitled file with white space in the middle.

7.  In the "Mouse Actions" section on the lefthand side, find the "doubleclick" word with a small camera picture.  Click on the camera icon.  You will now be able to create a rectangle anywhere on the desktop (outside of Sikulix).  Create a square around the shortcut created in step #4.  

8.  Separate from Sikulix, double click the shortcut created in step #4.

9.  Return to Sikulix. For second line of this automated sequence, type "wait(8)" with no quotes.

10.  Under "Mouse Actions" find the word "click" with a small camera icon.  Click this line (either the camera icon or the word "click").  Create a rectangle around the "Log in" button in the upper righthand corner.

11.  Separate from Sikulix, click the "Log in" button.

12.  Return to Sikulix from the "Keyboard Actions" section on the lefthand side, find the "type" word with a small icon of a camera followed by a comma and the word "text."  Click on the camera icon or anywhere associated with this "type...text" line.  You will now be able to create a rectangle anywhere on the desktop.  Put the mouse above the last two letters of "email address" and move the mouse to create a rectangle that includes one "s" and some of the field for the "email address:"  Release the mouse such that the rectangle captured has the middle point being in a clickable portion of the field for email address.  For the "text" in Sikulix, enter the email address that will log a user into rpaforum.net surrounded by quotes (e.g., "rpa@continualintegration.com").

13.  All the rest of these steps are done in Sikulix.  From the "Keyboard Actions" section on the lefthand side, find the "type" word with a small icon of a camera followed by a comma and the word "text."  Click on the camera icon or anywhere associated with this "type...text" line.  You will now be able to create a rectangle anywhere on the desktop.  Put the mouse above the last two letters of "password:" and move the mouse to create a rectangle that includes the letter "d" and some of the field for the "password:"  Release the mouse such that the rectangle captured has the middle point being in a clickable portion of the field for password.  For the "text" in Sikulix, enter the password that will log a user into rpaforum.net (e.g., "goodPassword").

14.  Under "Mouse Actions" find the word "click" with a small camera icon.  Click this line (either the camera icon or the word "click").  Create a rectangle around the "Log in" button under the "Password" icon.