Problem with custom print queue backend

I'm trying to write a custom backend (ksh script) for a print queue that will encrypt a file then FTP it to a server. I had been testing the script by just executing it by hand and giving it a file as an argument. When I run the script manually, everything works perfectly. But when I run the script by passing a document to the print queue, everything works except for the encryption. I tried modifying the script to dump some output of the gpg command to the files such as `gpg --list-keys`, and nothing is put in the file. It's like it is not even running gpg.

Please let me know if you need me to clarify the problem any more.