Category: ShellScript

  • Running a BASH script when my Laptop is opened at home – Part 2

    As I mentioned in this post I should be able to run a script to find my current gateway’s MAC address. With this info, I should be able to tell when I am home, and launch a script. In this post, I talk about sleepwatcher, which runs a script when the machine is woken up. Sleepwatcher…

  • Powershell script to install Cygwin

    I like having Cygwin installed on my machine, and since I always re-image, I needed a script to install Cygwin automatically. This will download and install Cygwin and install the openssh package.

  • Running a BASH script when my Laptop is opened at home – Part 1

    My laptop hard drive died. I was upset only because there was data on my laptop that had not been moved over to my desktop. My desktop has time machine and is rsynced to several other drives and locations. So I lost data. My own fault because I was not diligent in moving data off…

  • Comparing master and slave MySQL WordPress DBs

    My VPS host – Rackspace contacted me the other day to tell me that my host server became unresponsive. After it came back online I went to my MySQL replicated slave to check the status. The /var/log/mysqld.log said: Error reading packet from server: Client requested master to start replication from impossible position This article siad…

  • Drop all MySQL DBs (except mysql & information_schema)

    For some reason I can not remember the following command. I have been using it a lot lately when testing MySQL replication. mysql –skip-column-names –batch -e “show databases” | grep -E -v “mysql|information_schema” | xargs -I “@@” mysql -e “drop database @@” This will drop all DBs except the default mysql and information_schema dbs. Then…

  • Script to compare RPMs on two different CentOS servers

    I wanted to make sure that the same RPMs were installed on several servers. I wasn’t worried about versions of RPMs because everything should be kept up to date via yum. So I sat down and wrote the script below. It has been on my ToDo list for quite a while! This script connects to…

  • AutoSSH on CentOS

    I have been interested in MySQL replication over ssh and I wanted a way to make sure that the tunnel is always up. Everyone says to use AutoSSH. AutoSSH is not in EPEL, but is in rpmforge (Is that that same as DAG? Didn’t they merge?). I installed rpmforge: I don’t like to do the…

  • Mirror all MySQL DBs to the local machine

    Continuing on my quest to get MySQL replicating over ssh, I am using the following bash function to replicate all remote DBs locally:   Line 2 connects to the local AutoSSH tunnel and gets a list of all the remote DBs. Then we loop through the DBs and if there is not a DB locally…

  • OS X: Move files based on creation date

    I wanted to organize my flip videos – I wanted them moved into a folder named after their creation date. One of the scripts that I found uses ls’s “–time-style” parameter. BSD’s ls does not have this value. MacPorts’ coreutils port contains gls (GNU’s ls) that does support the parameter. So here is my script…

  • Check if a file exists on a remote server

    I was working on a copy WordPress site to a local machine script, and I wanted to check if the remote path was a WordPress site. Here is the code I used.