Dec 12

Useful little shell productivity tricks:

I work remotely a lot. To avoid the lag associated with VPN’s and
to assure I have all the tools I love, I setup up an environment in
Cygwin that gets me all I need to do development. The one thing
that’s irritating is when it comes time to test in the customers
environment (or just a far machine). This is where this little while
loop comes in. I open a new xterm and

while :
do
rsync -zav /home/tony/work/SomeCustomerProject/ Far.Box.com:/home/tony/work/SomeCustomerProject/
read foo # wait here until any key is hit
fortune # gives me unique phrase/thought to remind me if I’ve pushed or not
done

After running the loop I resize the window down to one or two lines. Whenever I want to rsync, I focus on it and hit return.

Other ways to simulate a Linux/UNIX environment:

Netcat is native to Cygwin however you have to choose it in the ’setup’ app.
# simulate a network server – cats whatever is written, great for text protocols/SOAP, etc. Binary protocols will work, but you’ll have to go out of your way to translate them.
while :; do nc -n -t -vv -l -p 4913 127.0.0.1 ; echo “—–” ; done

Cygwin also implements named pipes:
mknode /usr/local/groundwork/nagios/var/spool/nagios.cmd p
# keep the pipe read so it doesn’t block
echo “while :; do cat /usr/local/groundwork/nagios/var/spool/nagios.cmd; done”

Mysql compiles under Cygwin. I use mysql-5.0.33.tar.gz because I have it laying around. It installs all the libs you need to compile DBD::mysql. It has pretty bad performance, but is great for development and light loads.

# add a user to cygwin’s /etc/passwd:
mysql:unused_by_nt/2000/xp:1003:513:mysql user:/usr/local/var:/bin/bash

### config line
./configure –enable-assembler –with-mysqld-ldflags=-all-static
make install # installs to /usr/local/*

After that it’s just a regular MySQL setup.

-Tony

written by admin