I think you will find that you are actually getting a prompt back earlier, but are missing it because of output from pmserver or check_error?
You could try putting in an extra sleep 20, for example, after the check_error, and after 20 seconds your prompt should appear.
Annihilannic.