Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/fbsqlcom/public_html/youdidwhatwithtsql.com/wp-includes/pomo/plural-forms.php on line 210

Warning: Cannot modify header information - headers already sent by (output started at /home/fbsqlcom/public_html/youdidwhatwithtsql.com/wp-includes/pomo/plural-forms.php:210) in /home/fbsqlcom/public_html/youdidwhatwithtsql.com/wp-content/plugins/wordpress-mobile-pack/inc/class-wmp-cookie.php on line 50
youdidwhatwithtsql.com » Bash

Archive for the ‘Bash’ Category

Using Bash brace expansion to generate multiple files

I needed to generate a whole bunch of files, with identical content, for a recent task. You might automatically think of using a loop for such a task but there’s a much simpler method using brace expansion in the shell. I wanted to generate files in the following format… rhys-tmp01.txt rhys-tmp02.txt rhys-tmp03.txt … rhys-tmp91..txt rhys-tmp92.txt […]

Linux: Reclaim disk space used by “deleted” files

I had a misbehaving application consuming a large amount of space in /tmp. The files were visible in the /tmp volume itself but lsof allowed me to identify them. lsof -a +L1 -c s3fs /tmp COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME s3fs 59614 root 28u REG 253,3 584056832 0 22 /tmp/tmpfMIMLU4 […]

ssh-copy-id automation with a list of hosts

Here’s another version of my ssh-copy-id script this time using a text file containing a list of hosts. The hosts file should contain a single host per line. #!/bin/bash export SSH_USER=”user” read -s PASSWORD export PASSWORD while read HOST; do export HOST; expect -c ‘ set SSH_USER $env(SSH_USER) set HOST $env(HOST) set PASSWORD $env(PASSWORD) spawn […]

Automate ssh-copy-id with numbered hosts

Here’s a script I use to automate ssh-copy-id when I need to add a series of hosts using a incremental node number. For example… prod-db-server001 prod-db-server002 prod-db-server003 and so on. The script uses expect to perform its work. To adjust this for your own purposes you simply need to change the SSH_USER variable, the number […]

Using avahi / mDNS in a Vagrant project

I’m working on a project, with Vagrant and Ansible, to deploy a MongoDB Cluster. I needed name resolution to function between the VirtualBox VMs I was creating and didn’t want to hardcode anything in the hosts file. The solution I decided on uses avahi which essentially works like Apple Bonjour. As this solution has broader […]