Read a text file to connect to database!

Hi, I hope someone can help me. I am new to batch scripting. I want to read a file that has database namesand connect to each of them to get status and write output to a file. I'd like to do this from cmd command.