How to check from LaTeX whether a pfb file exists?

If you want to avoid shell-escape to enable you to run kpsewhich an alternative might be to put the fonts in the tex inputpath so you can use IfFileExists

\documentclass{article}

\begin{document}

\IfFileExists{stix-mathrm.pfb}{\show\yes}{\show\no}

\end{document}

This says no with the default path

$ pdflatex pp446
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./pp446.tex
LaTeX2e <2017-04-15>
Babel <3.13> and hyphenation patterns for 84 language(s) loaded.
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/size10.clo)) (./pp446.aux)
> \no=undefined.
\reserved@a ->\show \no 

l.5 ...xists{stix-mathrm.pfb}{\show\yes}{\show\no}

? 

but yes if you adjust the paths to append the type1 font path to the standard input path

$ TEXINPUTS=:\$T1FONTS pdflatex pp446
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./pp446.tex
LaTeX2e <2017-04-15>
Babel <3.13> and hyphenation patterns for 84 language(s) loaded.
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/size10.clo)) (./pp446.aux)
> \yes=undefined.
\reserved@a ->\show \yes 

l.5 ...xists{stix-mathrm.pfb}{\show\yes}{\show\no}

? 

You can use catchfile, whose interface is simpler than \read. This doesn't require shell escape (works with the restricted shell), but might not work in MiKTeX (sorry, can't test).

\documentclass{article}
\usepackage{catchfile}

\makeatletter
\newcommand{\IfExistsInTeXTrees}[1]{%
  \begingroup
  \CatchFileDef{\temp}{"|kpsewhich #1"}{\endlinechar=\m@ne}%
  \expandafter\endgroup
  \ifx\temp\@empty
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi
}
\makeatother

\begin{document}

\IfExistsInTeXTrees{stix-mathrm.pfb}{YES}{NO}

\IfExistsInTeXTrees{funny.pfb}{YES}{NO}

\end{document}

An expl3 implementation:

\documentclass{article}
\usepackage{expl3}

\ExplSyntaxOn

\prg_new_protected_conditional:Nnn \boris_if_exists_in_tex_trees:n { T,F,TF }
 {
  \tl_set_from_file:Nnn \l__boris_if_exists_temp_tl
   {
    \endlinechar=-1
   }
   {
    "|kpsewhich~#1"
   }
  \tl_if_blank:VTF \l__boris_if_exists_temp_tl
   {
    \prg_return_false:
   }
   {
    \prg_return_true:
   }
 }
\tl_new:N \l__boris_if_exists_temp_tl
\cs_new_eq:NN \IfExistsInTeXTreesTF \boris_if_exists_in_tex_trees:nTF
\cs_new_eq:NN \IfExistsInTeXTreesT \boris_if_exists_in_tex_trees:nT
\cs_new_eq:NN \IfExistsInTeXTreesF \boris_if_exists_in_tex_trees:nF

\ExplSyntaxOff

\begin{document}

\IfExistsInTeXTreesTF{stix-mathrm.pfb}{YES}{NO}

\IfExistsInTeXTreesT{stix-mathrm.pfb}{YES}

\IfExistsInTeXTreesTF{funny.pfb}{YES}{NO}

\IfExistsInTeXTreesF{funny.pfb}{NO}

\end{document}