How Do You Invoke the main Section of a Groovy Program?

Problem scenario
Your Groovy code has a section like this:

class Example {
static void main(String[] args) {

But this section above is not executing when you run your Groovy program. There are no errors however. How do you get it to execute?

Possible Solution #1
Remove lines of code (or statements) that are outside the “class Example {…”

Possible Solution #2
See this posting: How Do You Invoke a Class in a Groovy Program?

How Do You Use the aws update-kubeconfig Command?

Problem scenario
You want to manage your Amazon Kubernetes (i.e., EKS) cluster. You have installed the AWS CLI version on a Linux server, and you want to use the update-config or update-kubeconfig command.

But when you try you see messages like “error argument command: Invalid choice…” or “update-config: command not found”. You could not readily find an example. What should you do?

Solution
Background
The command is update-kubeconfig,

How Do You Interpret the dstat Utility’s Results on a Linux Server in AWS?

Problem scenario
You want to monitor network traffic on an EC-2 server’s NICs. You are not sure what to look for or what a baseline should look like. What do you do?

Solution
1. Install dstat. With a CentOS/RHEL/Fedora server, run this: sudo yum -y install dstat
2. Run this command: dstat -nt
3. With no network activity beyond the PuTTy session to the EC-2 server,

How Do You Terminate Pods in Kubernetes?

Problem scenario
You have some Pods in Kubernetes that you want deleted. What should you do?

Solution
1. Find the names. You can run this to find out: kubectl get pods

2. Run this command, but replace “foobar” with the name of the pod you want deleted: kubectl delete pods foobar

3. That should be it. Run kubectl get pods to verify deletion was successful.

How Do You Troubleshoot the Java Program Message “java.sql.SQLException: No database selected”

Problem scenario
Your Java program returns this message: “java.sql.SQLException: No database selected”
What should you do?

Possible Solution #1
Your SQL statement was appropriate for a database but not for the circumstance of connecting to a SQL instance. Try show databases; instead of the SQL you were running.

Possible Solution #2
Did you connect to the SQL instance you thought you connected to?

How Do You Get a List of Mail Queue IDs and Nothing Else?

Problem scenario
You use the mailq command. You see several emails have timed out. These emails are essentially in an “outbox” and a future delivery attempt is in the near future. How do you produce a list of the mail queue IDs by themselves?

Solution
If you want a list of the mail queue IDs in the queue, run this:
mailq | awk ‘{print $1}’ | grep -v ‘[[:punct:]]’ | sort | uniq

How Do You Troubleshoot the Error “sed: -e expression #1, char 1: unknown command: `””?

Problem scenario
You have a sed command in a script, but you get an error like one of the following:

sed: -e expression #1, char 1: unknown command: ” sed: -e expression #1, char 1: unknown command:”‘

How do you troubleshoot this?

Solution
You may need to assign variables like this:

var1=” foo””‘”” bar” # Place quotes around any unusual characters (e.g.,

How Do You Run a Java Program to Run SQL Commands Against a MySQL Database?

Problem scenario
You have a MySQL database. Rather than use a SQL front-end application, you want to write a Java program that will run a SQL statement against the database. What should you do?

Solution

1. Install the Java compiler if it is not already installed. If you need assistance, see this posting.

2. Run this command:
curl -Lk https://www.javatpoint.com/src/jdbc/mysql-connector.jar >