Archive for March, 2012


PHP shell scripts stop working if PHP executable is symlinked

March 9, 2012

I do web development for PHP on a MAC. Recently I installed the Acquia Dev desktop which is quite handy. It installed its own version of PHP to /Applications/acquia-drupal/php/bin/php

I needed to use this PHP from the command line so put a symnlink from /usr/bin/php -> /Applications/acquia-drupal/php/bin/php

Now, I also had phpcs installed, but moving PHP from an executable to a symmlink really upset it and it stopped working. Indeed, no shell script with the following shebang starting line would work anymore.


The solution is to instead use the following line at the top of those shell scripts instead:

#!/usr/bin/env php

So to make phpcs work again I had to edit /usr/bin/phpcs



Get old scanners working on Mac OSX (Lion)

March 3, 2012

My old scanner (Canon N67OU) stopped working on the update to Lion. After a bit of web searching I found the following brilliant project which magically works with old scanners from the command line:

Install the lib-usb package first followed by the SANE backends then TWAIN SANE Interface.

I found I could then scan from the command line with the following:

scanimage –format=tiff -x 215 -y 297 –depth 8 –resolution 100 > scan.tiff

For more help try,
scanimage –help

Or the FAQ online here:


Manage multiple Linux users editing the same projects

March 1, 2012

I work on projects on remote servers where a number of developers might login and edit a file. This usually results in the file permissions changing so that they own it which can cause problems. A simple solution is for everyone to be a member of the same group, then make it so that by default it is that group that is set on a file when someone creates it. We also then want to set the group write flag by default as well so that anyone can edit that file.

The steps involved in setting this up on a server are as follows.

— create a new group everyone will share (mygroup)
groupadd mygroup

— create any new users (if required, this can be skipped if you have existing users)
useradd -G mygroup -m myusername
passwd myusername

— Make the default group for a user to be mygroup so everyone in that group can access their files
usermod -g mygroup myusername

— Set the global umask in the global bashrc file so that all users set group write on files (needs everyone to logout and in again)
vim /etc/bashrc
umask 002

Note for the bashrc thing to work it has to be called from the user’s local .bashrc file intheir home directory. Most linux distros do this by default but it is possible for individuals to remove the include for the global bashrc which will then mean that group write is not set on files they create. The bit in the users .bashrc file that includes the global bashrc looks like this…

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc

Now if your shared work is in /var/www/html for example, you’ll need to change the group owner on all files in that directory to the new mygroup

chgrp -R mygroup /var/www/html

And you will also want to make sure every file is writable by the group

chmod -R g+w /var/www/html