Use the additional parameter for shellescape() only for system calls of the form execute '!...', not for system(...).