@Flint-Olsen, yeah, it will work every time for a given login setup. I meant that it would be very difficult to design an universal script that will be able to login to all the login screens out there.

Yes, you should be able to send POST request via curl. You will need to go into the HTML file of the setup screen to see what kind of information is passed to the router via the POST request. Then all you will need to do is to simulate that request, and you should be able to log in.