Well….there could be a number of reasons for this, but one gotcha reared it ugly head this week…

In a ksh script was a zip command being called something like this:

export ZIP=/usr/bin/zip
export ZIPFILE=testfile
export SOURCE_DIR=/usr/local/files
$ZIP -j $ZIPFILE $SOURCE_DIR/*

Now this doesn’t look too bad, however, when run it seems the exported $ZIP variable clashes with a variable used within the zip binary itself. So the command fails with an error because it tries to create a zip file called /usr/bin/zip.zip, and the user running this script does not have permission to write to that directory.

The fix is simply to change $ZIP to something else, like $ZIPBIN.