PS misprint: the content of the script.sh file is
if /usr/texbin/pdflatex -output-directory /User/piero/Desktop/prova
-interaction=nonstopmode /dev/stdin; then
echo '<meta http-equiv="refresh" content="0; tm-file:///User/piero/Desktop/prova/stdin.pdf">'
fi
(in my original post the path to the pdf file was incorrect)