passing bash variable to perl command in bash script

Recently I tried passing a bash variable to perl command in bash script, it didn’t end well.

Troy Engel from http://tacticalvim.wordpress.com/ was nice enough to point out the issue:

use sed instead of perl for what you need; it’s simpler, faster and uses the bash variables easily.

I set up a test script /home/someuser/test.sh to show:

. . . → Read More: passing bash variable to perl command in bash script

sed delete all lines after

Objective: Prep dev httpd.conf for production

Tasks:

Remove jenkins virtual host entry (which starts with a comment line “#Start Jenkins”) Replace .dev with nothing (ex: www.dev.example.com becomes www.example.com) Replace debug with error (ex: Loglevel debug becomes Loglevel error) Sed to remove lines after match

In this example we will use sed delete all lines after . . . → Read More: sed delete all lines after

redhat add multiple users

useradd script

to add multiple users to a system and force them to change their password upon login try the following script:

Redhat

The above script will add three users to the system (someuser anotheruser yetanotheruser) with the password “password” and set the password age to zero. This forces them to change their password . . . → Read More: redhat add multiple users

Bash Server Backup Script

I’ve created a Bash Server Backup Script that will backup your MySQL databases (each database separately in to .sql and .xml files) and your main directories (/var/log, /var/www/html, /etc, /home, /root) to a timestamped directory. Feel free to re-use or hack up however you’d like

Here’s my Bash Server Backup Script: Download the script here . . . → Read More: Bash Server Backup Script

parse apache access log entries to find top user agents, top urls and top IPs

This script will allow you to see the top user agents, urls, IPs for your log files:

 

Script name: ls-httpd

kill liferay script

Here’s a bash kill liferay script!

This should kill any running liferay or liferay social office on a linux system.

Open up your favorite editor and paste this in #!/bin/bash # #Script name: kill_liferay.sh # #Purpose: To kill any running instance of liferay on a linux system # #Usage: ./kill_liferay.sh # for pid in `ps . . . → Read More: kill liferay script

gzip log files older than one day

To Gzip files older than one day place this in a cronjob: TODAY=`date +”%Y-%m-%d”`

for logfile in /var/log/tomcat6/*.log; do # grab the %Y-%m-%d out of the name DTS=${logfile:(-14):10} if [ $DTS != $TODAY ]; then # compress in place gzip $logfile fi done

kill orphaned httpd processes

to kill orphaned httpd processes create a script called killhttpd.sh with the following code

bash diff alternative

How to setup a bash diff alternative

Copy and paste the below in to /usr/bin/diff2

Now make it executable

Example Usage: