Some comments on your last post.
Kosice is a nice city easily doable in a day. We were there this summer but unfortunately on a Sunday which meant the town was very quiet. We traveled here from Eger but Kosice is easy to get to as there are IC trains from Budapest that end here. You can check the DB train site for onward train connections. If you go this route you can also check the Slovakian transport site for connections (bus/train/etc.)
http://cp.atlas.sk/vlakbus/spojenie/
Keep in mind that Kosice is close enough to Budapest that I don't think an overnight train will be an option. Also, as stated in other threads, lots of folks (including my wife and I) can't sleep on night trains.
Lviv, Ukraine is not an option. It is quite far away and takes lots of time unless you fly. We did this this summer taking 2 buses to travel from Kosice to Uzhgorod (Ukraine) taking about 2.5 hours. This was followed by a 6.5 hr train ride through the Carpathian mountains to Lviv. The other way to get to Lviv is from E. Poland (Przemysl) but here too the route takes time.
One suggestion is to travel to Krakow and then move to Warsaw - worth a couple of days and only 2.5 hrs on the train from Krakow if I remember correctly.
Edited to add - maybe you were considering doing Lviv after visiting Krakow in which case this may be feasible if you plan on flying out of Lviv. In this case, check out the Lonelyplanet thorntree forum for details on the border crossing (going into Ukraine) which can be time consuming due to the smuggling taking place