Will that work as a temporary filling until I can go see a dentist for a cavity?

Go to your pharmacy. Temporary dental filling material is available for purchase over the counter at your local pharmacy. It may seem self-evident, but needs to be stressed: temporary filling material is only for temporary use, and will do nothing to prevent the progression of tooth decay or avert dental infection. You should arrange for professional dental service at your earliest opportunity.
What Work? There are some temp materials at some pharmacies that you can place but they are limited and getting to the dentist is the best option.

Related Questions

I think I have a tooth cavity but I can´t see a dentist yet as am traveling far away. Is there anything I can do meanwhile? Am I gonna need a filling?

Not really. Need to see a dentist as soon as possible to prevent spread of tooth decay which can lead to potential tooth infection. Read more...
Tough to tell... Usually, the longer you wait, the worse and more expensive treatments get. Consider seeing a dentist where you are traveling just in case. Otherwise, keep the area as clean as possible, brush your teeth and rinse often. Not much you can do other than that, short of getting it checked out to find out exactly whats going on. Read more...

My molar has a cavity under a filling. I'm having pain but not 100% sure it's that tooth as the pain is more in my jaw area. Should I see a dentist?

See your dentist. The cavity is getting closer to the tooth pulp and it may spread to other parts of the body. The pain may reside in the pulp as toothache or spread from the root causing jaw pain which appears to be what you have. See your dentist for evaluation and treatment ASAP. Read more...
Of course. You've got a carious lesion under an old filling.. at a minimum you need a new filling. The longer you wait, the more complex your treatment will be. Call for an appointment. Read more...
Do not delay. Yes, you should see a Dentist immediately. Delay will only allow cavity (infection) to spread, destroy more tooth tissue, and more surrounding bone/gum. Call now! Read more...