in reply to script hangs after executing program

As an alternative to adding debug print statements around your system statement, you can use ps -fu <user running script> from another terminal to determine if $prog is still an active process when you think it is hung.

If it is still running, you may be able to get some idea what it is doing by running strace -p <pid of $prog>.
If this generates a continuous stream of output, $prog may be looping trying to access some resource.
If it only generates a few lines of output it may be waiting for some user input.

Both of these suggestions are specific to Linux/UNIX. I am not sure if there are Windows equivalents.