t_critical= tinv(1-alpha/2,n-2);
where alpha is confidence level (e.g. alpha=0.05 for 95% confidence level);
Pval=2*(1-tcdf(abs(t),n-2))
where t is our calculated value of t statistics.
With regard to Octave, it depends which version you use. You may find that instead of tint and tcdf there are t_int and t_cdf functions.