Take the Ernakulam express and enjoy a one night stay at Coimbatore and then catch the early morning Nilagiri Express.
Take the Kochuveli Express and arrange for a four hour accomodation at Coimbatore
Option 3 and best option:
Take a bus from Bangalore to Coimbatore, It reaches Coimbatore by 4.30am and then quickly move to the railway station to catch the Nilagiri Express
The Nilagiri express takes an hour to reach Mettupalyam from where you can catch the Toy train to Ooty. Supposedly the ride in the toy train is mesmerising.
From Mettupalyam, the Udagamandalam Passenger train takes around 5 hours to reach Ooty, also called as Udagamandalam.