compare is the function in test.sh, not the command /usr/bin/compare function compare { metric=$1 image1=$2 image2=$3 tolerance=$4 inversion=$5 channel=$6 if [ "$metric" = "PSNR" ]; then script="check_compare_PSNR.pl" else script="check_compare.pl" fi if [ -z "$channel" ]; then channel="Total" fi if [ ! -f $image1 ]; then echo "KO" return fi if [ ! -f $image2 ]; then echo "KO" return fi gm compare -metric $metric $image1 $image2 | grep $channel | perl $script $tolerance $inversion } So calling 'compare manually' without the function defined in the scope of executing compare is not the same as test.sh does PAE does not reference a file when calling the compare function, but to the first parameter, metrics. The name is kinda unfortunate, considering that ImageMAgick delivers a binary with this name