Helps to keep moving and have a task on hand. You only really feel tired once you stop moving. If you're not moving, keeping your body preoccupied somehow (I like to throw a handful of sunflower seeds in my mouth or some chewing tobacco if you hate yourself) helps you stay awake and focused.
The problem is we spent a lot of time laying down in the dirt, not moving for hours looking down the sight a rifle and fighting with ourselves to stay awake. That's when a buddy comes in handy, a lot. But there were times when I spent an hour or two in a state of neither really being awake nor asleep. It definitely sucks.
In reality the best thing you can do is get your work done thoroughly and complete your task so you can finally go to sleep. You can have all the caffeine you can find to buy yourself time, but you better have a good reason for depriving yourself of sleep, and hope that reason is a clear-cut mission you can accomplish soon.
Long story longer I don't have an answer for your question cause there really isn't one, you just have to learn to succeed in that state of mind :P