Append exit to the script after qsub

I am trying to append exit statement to my pbs script file using a hook.
This is the hook that I have created

import pbs

def job_submission_hook(event):

    job = event.job
    job_script = job.script

    # Append 'exit' to the job script
    job.script = job_script.rstrip() + "\nexit\n"

job_submission_hook(pbs.event())

It gives the following error-

qsub: request rejected as filter hook ‘append_exit’ encountered an exception. Please inform Admin

I believe the job object does not have a “script” attribute.

What are you trying to accomplish? Perhaps there is another way to do it.

Also, blindly adding “exit” to the PBS script is a bad idea. The job script can include data after the command portion. Or, the shell used to interpret the script (qsub -S) might not be sh or csh, so “exit” might not be appropriate.