Skip to main content


Showing posts from April, 2016

Bash Ctrl-C Cleanup

Most scripts are pretty simple things, but sometimes one writes a monster and it may create several temporary files, lock files and other detritus while running.  Sometimes you will be nice and delete the junk before the script exits.   However, if the user would terminate the script forcefully with Ctrl-C or kill, then the garbage will not be removed. Here is the proper way to handle that in Bash:   # Trap keyboard interrupt (control-c)  trap control_c 0 SIGHUP SIGINT SIGQUIT SIGABRT SIGKILL SIGALRM SIGSEGV SIGTERM  control_c()  # Control-C Press  {    cleanup    exit $?  }  cleanup()  {    rm /var/lock/mylockfile    return $?  } La voila! Herman

A Few Pros and Cons of UNIX

The problem with pros and cons discussions on operating systems, is that the people who need to read them won't, but as the old sage said: Why do you have a mind, if you cannot change it? USB Support The Windows device names of USB serial ports keep on changing.  I have seen a machine in our lab using COM57:.  That means that half a hundred times, some poor engineer sat in front of that machine and wondered why on earth his serial port wasn't working. Trying to deploy a system that uses USB serial ports on Windows is a nightmare, since each and every machine has a different setup and it changes at a whim, so you need to open up low level configuration to the end user and try to explain to him how to change it in the manual and have a technician on standby to support all the users who won't read the manuals. IT services also like to disable USB mass storage support, since Windows suffers from a 25 year old security bug that Microsoft is unable to fix .  So whenev