How Do You Display the VPC Peering Connections with Boto3?

Problem scenario
You want to list all the VPC Peering Connections for a specific region using Python.

You want the equivalent of aws ec2 describe-vpc-peering-connections

How do you show (retrieve or fetch) the VPC peering connections using Boto3?

Solution

import boto3
contint = boto3.client(‘ec2’)
var1 = contint.describe_vpc_peering_connections()
print(var1) …

Can You Use the MVC (Model-View-Controller) on Linux?

Question
Whenever you read about the MVC, it always involves Microsoft (e.g., and ASP or .NET). Is there a way to use the MVC on purely Linux?

Answer #1
Yes. The ASP.NET MVC framework of the model-view-controller is a Microsoft implementation of it. The MVC generically can be used as an architectural pattern using programming languages on a Linux server. To read more about it,

In Python, How Do You Call a Bound Function as a New Thread with the threading Module?

Problem scenario
You want to write a program to call a bound function in a new thread. How do you do this?

Solution
Run this program (e.g., python foobar.py):

from threading import Thread

class mighty:
def good():
print(“Good”)

def contint():
print(“Hello!”)

if __name__ == “__main__”:
thread = Thread(mighty.good())
thread.start()
thread.join()
print(“thread finished…exiting”) …

How Do You Eliminate Unwanted Indentation at the Top of Text in WordPress Postings?

Problem scenario
You are using WordPress for your website. In some text, paragraph blocks you use with the “<Code” syntax on some lines of computer programming code. The first word is indented from the left. You do not want this indenting. What should you do so your code looks like code but does not have this indentation problem?

Solution
Do not use the “Paragraph” formatting.

How Do You Assign a Variable in JavaScript from User Input?

Problem scenario
You want to read input and assign it as a variable in JavaScript. What should you do?

Solution
Create a .html file, saved directly on your desktop or in a /var/www/html/ directory on a web server, with the follow content to illustrate how to do this (then open it in a web browser):

<!DOCTYPE html<html<body<h2Use JavaScript to Change Text</h2<pThis example writes “Hello in JavaScript from Continualintegration.com!” into an HTML element with id=”demo”:</p<p id=”demo”</p<scriptvar foo = prompt(“Please enter input and press enter”); …

How Do You Print the Email Addresses That Bounced after They Were Sent from Your Postfix Server?

Problem scenario
You have installed Postfix (e.g., version 3.2.0) on your Linux server. You know several emails that were sent (or attempted to be delivered) bounced. You want to have a list of those unique email addresses by themselves. What do you do?

Solution
Run this command:

sudo cat /var/log/mail | grep bounce | awk ‘ $0 ~ /@/ {print $5}’ | awk ‘{FS=”to=”; …

How Do You Troubleshoot a Bash Script with the Error “No such file or directory”?

Problem scenario
An “if” statement in Bash is throwing an error message “No such file or directory.” What do you do?

Possible solution #1
Replace the parentheses around the arithmetical comparison with double parentheses. Instead of this:

if ( $numlines < 5); then

Use this:

if (( $numlines < 5)); then

Possible solution #2
Replace the “[]” with “(())”.

How Do You Get Your Linux Email Server to Deliver Email Consistently?

Problem scenario
You quickly set up an email server on a virtual machine in a public cloud. Some emails from the server are being received but some are not being received. What could be wrong?

Solution
1. If you are using Postfix, check the files in these locations:

/var/spool/postfix/private/bounce
/var/spool/postfix/bounce
/usr/lib/postfix/bounce

2. Look at the file /var/log/mail for clues about what could be wrong.