May I ask what the application is for? Will help better understand how to make this work for you possibly as for I have played in this area of Computer Telecommunications before with other projects of my own. Such as a project that called me when a problem happened and told me what the problem was.
From this it looks like you are just trying to get connected with ISP maybe or another system modem to modem?
Thinking you may be able to supress the echo output of the error message and test it for connected text output or other, and if other ( not matching a successful connection text output ) then goto beginning of batch to redial.