$M$ is compact iff $f:M\to\mathbb{R}$ has a positive infimum. 
A metric space $M$ is compact if, and only if, every positive and real-valued continuous function on $M$ has a positive infimum.

My approach :
If $M$ is compact and $f:M\to\mathbb{R}$ a real-value continuous and positive on $M$. Then $f(M)\subset\mathbb{R}$ is a subset closed and bounded of $\mathbb{R}$. Let $\alpha=\inf f(M)$ and $f$ is positive, then $\alpha>0$. On the other hand, How I should prove this?? Let $f:M\to\mathbb{R}$ continuos and positive function on $M$, with infimums postive, then $M$ is compact. Regards!
 A: If $f$ has no infimum $> 0$, then $f^{-1}((\epsilon, \infty)) \ne M$ for any $\epsilon > 0$.
A very late edit:
After DrHal's comment brought my attention back to this, I realized it had never been completely answered. As noted in the comments, my answer above only shows that $M$ compact implies that all positive functions have a positive infimum. Daron's answer shows that all positive functions having a positive infimum implies that $M$ is complete. But it does not show that $M$ is totally bounded. So I would like to address this.
But first, there is a much simpler proof of completeness than Daron provides. Assume $(M, d)$ has the property that all positive functions have a positive infimum. Let $\{a_n\}_{n\in \Bbb N} \subseteq M$ be a Cauchy sequence. Assume that $\{a_n\}$ does not converge. Define $$f\ :\ M \to \Bbb R\ :\ x \mapsto \lim_n\ d(x, a_n)$$
Then $f$ is well-defined by the Cauchy condition and can easily be shown to be continuous and is clearly $\ge 0$. $f(x) = 0$ would imply $a_n \to x$, so $f$ must be positive. But by the Cauchy condition, $\lim_n f(a_n) = 0$, contradicting that $f$ has a positive infimum. Thus $\{a_n\}$ must converge.
To show that $M$ is totally bounded, another proof-by-contradiction can be used: if $M$ is not totally bounded, then there is an $\epsilon > 0$ such that $M$ is not covered by a finite number of balls of radius $2\epsilon$. Start with an arbitrary point $a_0$, then recursively choose $a_n$ to be at least $2\epsilon$ away for $a_k$ for all $k < n$. The sequence $\{a_n\}$ has the property that for all $x \in M$, there is at most one $n$ such that $d(x, a_n) < \epsilon$. Choose a continuous function $\varphi\ :\ \Bbb R \to [0, 1]$ such that $\varphi(0) = 1$ and $\varphi = 0$ outside of $(-\epsilon, \epsilon)$. Define $$h\ :\ M \to \Bbb R\ :\ x \to \sum_n\ n\ \varphi(d(x, a_n))$$
For any $x$, the sum has at most one non-zero entry, so it is finite and the continuity of $h$ follows from that of $\varphi$ and $d$. Obviously $h \ge 0$, and for all $n, h(a_n) = n$, so it is unbounded. This means that $$f\ :\ M \to \Bbb R\ :\ x \to \frac 1{1 + h(x)}$$
is positive and continuous, but has $0$ as its infimum. A contradiction.
A: For the reverse implication suppose every positive function has positive infimum. Then the reciprocal of every positive function (being positive) has a positive infimum, say $\epsilon$. So the original function was bounded by $1/\epsilon$. Therefore every positive function is bounded. Now let $g \colon M \to \mathbb R$ be an arbitrary function and consider $G(x)=|g(x)|+1$. That is positive so it is bounded. This shows $g$ is bounded because if it goes to infinity in either direction then $G$ goes to positive infinity, contradicting how it's bounded. We conclude every continuous function on $M$ is bounded. This is known as pseudocompactness. For the remainder of the proof I refer you here.
