Well, it's a bad idea in general, but you can make it less bad. Couple of tips:
- Take 10 minute breaks every hour
- Every couple (3-4) of hours exercise for about 15 mins (high intensity interval training really wakes you up for example)
- Eat low-carb meals (carbs make you drowsy)
- Easy on the caffeine. When it wears off you'll get really tired.
If you can't avoid sleep, have a coffee, and then take a 20 - 30 minute powernap. The nap will free receptors for the caffeine to attach to, so it'll work better after you wake up.