Slaptijack Title

Two Column for Loop in bash

by Scott Hebert
I had this interesting question the other day. Someone had a file with two columns of data in it. They wanted to assign each column to a different variable and then take action using those two variables. Here's the example I wrote for them: IFS=$'n'; for LINE in $(cat data_file); do V...

Read More →

OpenSSH: Using a Bastion Host

by Scott Hebert
Quick and dirty OpenSSH configlet here. If you have a set of hosts or devices that require you to first jump through a bastion host, the following will allow you to run a single ssh command: Host * ProxyCommand ssh -A <bastion_host> nc %h %p Change the Host * line to best match the h...

Read More →

Interleave Two Lists of Variable Length (Python)

by Scott Hebert
I was recently asked to take two lists and interleave them. Although I can not think of a scenario off the top of my head where this might be useful, it doesn't strike me as a completely silly thing to do. StackOverflow's top answer for this problem uses itertools.chain.from_iterable() and iterto...

Read More →

Socket Timeouts in urllib2

by Scott Hebert
One of my scripts that makes an API call has been failing silently lately. It appears that the connection is timing out, but I am not catching that particular error. So, I fixed that. @@ -8,6 +8,7 @@ import os import random import shelve +import socket import sys import time import urllib2 ...

Read More →

Cache has broken packages, exiting

by Scott Hebert
I've been getting the following error from cron.daily in my inbox lately: /etc/cron.daily/apt: Cache has broken packages, exiting That's an annoying email to get everyday. I decided I would apt-get clean and that would probably fix the problem: This is an older Ubuntu server running 12.04.5 ...

Read More →