How Do You Troubleshoot the sonar-scanner CLI Not Working?

Problem scenario
You run sonar-scanner from the command prompt, but you receive an error. The error looks like one of the following:

“Task ‘-x’ does not exist. Please use ‘list’ task to see all available tasks”

“You must define the folowing mandatory properties for ‘Unknown’: sonar.projectKey, sonar.sources”

What should you do to get sonar-scanner to work?

Solution
Run the sonar-scanner command from a local directory where you have sonar-project.properties.

 » Read more..

How Do You Get Python to Compute How Long Something Took?

Problem scenario
You want to check the runtime duration of a section of Python code. How do you compute the amount of time something took in Python?

Solution
Write a program like this:

import datetime, time
t1 = datetime.datetime.now()
time.sleep(5) # replace this line with the section of code you want to time
t2 = datetime.datetime.now()
t3 = t2 – t1
print(“Time format is in hours:minutes:seconds:seconds_decimals”)
print(t3)  » Read more..

How Do You Install Maven on Linux?

Problem scenario
How do you install Apache Maven on any distribution of Linux?

Solution
This is based on Apache Maven 3.5.2.*

curl http://mirrors.advancedhosters.com/apache/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz /tmp/apache-maven-3.5.2-bin.tar.gz
sudo tar -xzvf apache-maven-3.5.2-bin.tar.gz
sudo mv apache-maven-3.5.2 /opt/maven
export M2_HOME=/opt/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
source ~/.bashrc
mvn -v

*You can change the directions if you want. You can get the latest installation media from here:
https://maven.apache.org/download.cgi

 » Read more..

How Do You Solve This Problem “Error: Could not find or load main class org.apache.hadoop.util.VersionInfo”

Problem scenario
You run “hadoop version” but you receive this message “Error: Could not find or load main class org.apache.hadoop.util.VersionInfo”. What do you do?

Possible Solution #1
Use “sudo ” before the “hadoop version” command.

Possible Solution #2
Use “sudo -i ” before the “hadoop version” command.

Possible Solution #3
Use a different user.

 » Read more..

How Do You Get Hadoop Commands to Work from Any Directory without Using the Full Path?

Problem scenario
Hadoop is installed on Linux. But hadoop version and other hadoop commands are not working. What should you do?

Solution
Find the hadoop executable in a directory named bin. It is often “/usr/local/hadoop/bin/hadoop”. Ultimately you need to find the directory that houses this “bin.” has a subdirectory with “bin” and “hadoop” inside, run these two commands:

sudo find / -name hadoop -type f
whereis hadoop

Run these commands interactively where “/usr/local/hadoop” is the directory that is the parent of the subdirectory named “bin” that is the parent of the hadoop executable.

 » Read more..

What Command Do You Use to Check if Splunk is Installed?

Problem scenario
You want to find out what version of Splunk you are using. What command do you run?

Solution
Run this command: sudo /opt/splunk/bin/splunk version

If it does not work, run this command: sudo find / -name splunk -type f
Then run sudo /path/found/above/splunk/ version

 » Read more..

How Do You Troubleshoot the Go Programming Error ‘non-name m1[“foo”] on left side of :=’?

Problem scenario
You are running a Go program. You see this message about “command-line-arguments”:

non-name m1[“foo”] on left side of :=

What should you do?

Possible Solution
Can you try to use “=” instead of “:=”? This may fix your problem.

The := is a variable declaration and an assignment. If your map has been declared, individual values in it should be assigned with an “=” (equals sign).

 » Read more..

How Do You Use a Function in Golang?

Solution
Prerequisite
This assumes that you have installed Golang; if you need assistance with this, see this posting.

Procedures
1. Create a file called b.go with this as the content:

package main

import “fmt”

// ContintFunction will display a message
func ContintFunction() {
fmt.Println(“Hello from Continual Integration”)
}

func main() {
ContintFunction()
}

2.

 » Read more..

How Do You Find out What Packages You Can Install That Are Related to a Certain Category when Using Ubuntu Linux?

Problem scenario
You want to find what Java packages are available on the configured repositories of the Linux server you are using. What do you do?

Solution

Run a command like this: apt-cache search java

You can replace “java” with a word of the package you want to install.

If you want to learn more about the package and have its exact name,

 » Read more..

How Do You Find out What Packages You Can Install That Are Related to a Certain Category when Using Linux SUSE?

Problem scenario
You want to find what Java packages are available on the configured repositories of the Linux SUSE server you are using. What do you do?

Solution
Run this command: zypper se java

You can replace “java” with a word of the package you want to install.

 » Read more..