Naming is something like attaching a label to a thingLudwig Wittgenstein
1 - 3 
Also relates to Operating Systems
Firstly apologies to anyone who has felt the urge to follow my blog with such a sporadic posting of entries over the last 18 months. Becoming a dad has compelled me to reassign my priorities and blogging time has really been under the kosh.
Anyway, time is of the essence so I must not ramble. Virtualization is the name of the game currently and I have been hard at work and play test driving a broad array of Linux platforms on both a Windows Vista host and a Tiger host. Since last posting my excitement at discovering VMWare Player back in May I have upgraded to Fusion and Workstation and started building virtual operating systems from scratch using ISO boot disks. I have one goal in mind and that is to create my development nirvana - a perfect setup of multiple displays and desktops that will allow me to meet my objectives in the quickest possible time using the minimum number of actual platforms.
I will come back to this in the coming weeks and discuss what desktops and operating systems I have gone for. Watch this space…
Posted on Jul 24, 2008 at 19:43:10.
Earlier I was setting up a couple of shell scripts to allow me to quickly switch between PHP versions on the Apache web server and enable/disable my unit testing environment in OS X. Along the lines of:
apachectl stop httpd -f /usr/local/php5/httpd.conf
Since such scripts must be run as root user I wanted to concote a little script to check I had used sudo to run the commands (as I have a habit of forgetting!). Firstly I came up with the following:
#!/bin/sh # verify-su umask 222 touch /tmp/user-status echo `whoami` 2> /dev/null >| /tmp/user-status if [ $? -ne 0 ] ; then if [ $# -eq 0 ] ; then "This command must be run with root privileges!" else "$1 must be run with root privileges!" fi exit 1 fi \rm /tmp/user-status exit 0
A file is created with read only permissions (by temporarily changing
umask) and then the script
attempts to write to it. The output redirection to file will only succeed if the script is run as root (the superuser).
In running this without the
rm command I discovered that a script executed with sudo will return root from the
whoami command instead of the user name I am currently logged in with. So this could actually be simplified considerably to:
if [ `whoami` != 'root' ] ; then # etc … exit 1 else exit 0 fi
There is always a simpler way to do things!
Also relates to Shell Scripting
I have had Cygwin sitting on my Windows OS for some time now, and only utilised it occasionally to get to grips with the intricacies of the UNIX system. I finally decided the other day to put it to work a bit, and start learning Shell scripting. The main incentive being that my text editors and macros were not reducing the workload enough in reworking old web sites to improved standards and accessibility levels. In only a few days graft, I am already revelling in the offerings of text utilities like SED, AWK, TR and GREP, and I have a few reasonable scripts to rework the content of some of my HTML files.
Google Search), but this repeatedly crashed my system, and the tools available in the Bash shell appear
var obj or
validate()). As an initial shell command, I came up with this little pipeline:
# place a dot separator in variable declaration sed -e 's/var /var./g' # place a dot separator in function declaration -e 's/function /function./g' # remove all comments -e 's///.*[a-z]$//' testfile | # remove all whitespace tr -d '[:space:]' | # remove dot separator in variable declaration sed -e 's/var./var /g' # remove dot separator in function declaration -e 's/function./function /g'
[ Back To Top ]
Copyright © 2002-2017 Severn Solutions.