Switched the use of 'which' to the more compliant and compatible 'type', and ensured only scripts cjdscript is meant to start can be started