How Do You Print out Lines of a File One-by-One with No Commas and No Semicolons?

Problem scenario
You have a flat file that may have lines that terminate (or end) with semicolons or commas. You want to print one line of this file at a time without commas or semicolons. How do you do this?

Prerequisite
You have a file named “list” (with no extension) in the same directory as this script below.

Solution
Run this script:

while read list;  » Read more..

How Do You Automate a telnet Session to Send a Postfix Email on a Linux Server?

Problem scenario
You want to create a script that will send an email from a Linux server. You want it to use telnet. How do you automatically send an email using telnet?

Solution
Prerequisite
Set up Postfix. If you are running SUSE, see this posting. If you are running a RedHat derivative, see this posting.

 » Read more..

How Do You Install Grails on Any Type of Linux server?

Problem scenario
You want to install Grails on a Linux server. What do you do?

Solution
Prerequisite
Your server has access to the internet.

Procedures
Run these commands:

sudo curl -s https://get.sdkman.io | sudo bash
sudo su –
sdk install grails

# We know this isn’t a best practice to install things as root,

 » Read more..

How Do You Configure Linux CentOS 6.x to Accept SSH Connections?

Problem scenario
You try to use PuTTY to connect to a Linux CentOS 6.x server. You get the message “Network error: Connection refused.” What should you do?

Solution
Prerequisite
This assumes that there is no software or hardware firewall blocking port 22. You may want to use nmap or a Windows PowerShell port tester to verify port 22 is open.

 » Read more..

How Do You Send an Email from a Postfix Email Server with A “Reply-to” Email Address of Your Choosing?

Problem scenario
You are using Linux. You want to send emails from your server directly (e.g., from the command prompt using telnet and helo commands) with a customized “Reply-To” email address. How do you do this so the recipient clicks “reply” the “To:” field will be pre-populated.

Prerequisite
Install Postfix. See one this posting if you are using Linux SUSE;

 » Read more..

How Do You Troubleshoot “550 5.1.1 johndoe@example.com: Recipient address rejected: User unknown in local recipient table”?

Problem scenario
You are using Postfix. You are trying to send emails directly from the Postfix server. After you use telnet and helo commands, you enter a recipient like this:

rcpt to: johndoe@example.com

But you get this error:

“550 5.1.1 johndoe@example.com: Recipient address rejected: User unknown in local recipient table”

What should you do?

Root cause
If you change the /etc/postfix/main.cf file to have emails use a “reply-to” of example.com,

 » Read more..

In Python How Do You Print Three Integers Separated by a Space on the Same Line?

Problem scenario
You want to print three integers. You do not want to convert them to be part of a string. You want a space to separate each integer. How do you do this in Python?

Solution
Assuming your variables are x, y, and z, and they are integers, use a line like this:

print(x, y, z)

Here is a complete program that proves it works:

x = 5
y = 3
z = 100
print(x,  » Read more..

How Do You Write a Python Program to Download the Images of a Website?

Problem scenario
You want to download pictures (e.g., .png, .jpeg etc.) from websites. How do you use Python to download such files?

Solution
Use this program with a subdirectory in the directory that this program resides to receive the picture files.

“””
dwldimages.py
Downloads all the images on the supplied URL, and saves them to the
specified output file (“/test/” by default)

Usage:
python dwldimages.py http://example.com/ /tmp/test/ # where /tmp/test/ is the directory you want to save the image files to.  » Read more..

How Do You Assign a Variable in Groovy to Be an Integer Value?

Problem scenario
A Groovy program is returning an incorrect value for an integer variable. What is wrong?

Possible solution #1
Check the logic of your program. Use the println command to see the earliest point when this variable is assigned an incorrect value. This helps you pinpoint the problem.

Possible solution #2
Is the variable being assigned a number in quotes like this?

 » Read more..

Why Cannot You Ping an IP Address of an AWS Server When the Security Group Should Allow for Pinging?

Problem scenario
In AWS you manually added a Security Group rule for the source of a given IP address. This IP address is either the internal or external IP address. You can ping one of them (either the internal or external IP address). Why cannot you ping each IP address?

Solution
Check to see if a firewall is running on the Linux server.

 » Read more..