You don’t say what sort of shell you’re running. If you’re using sh/bash, try
sh -x script_name
to run your script in a verbose/debug mode. This will dump out all the commands you execute, variable values etc. You don’t want to do this normally since it’ll provide a ton of output, but it’s useful to work out what’s going on.
As noted in the comments, you can add this flag to your #!/bin/bash invocation in your script.