In Linux you can search the list of currently running processes using the command ps aux. For me an entry of pdflatex with --output-dir looks like this:
marijn 94217 0.0 0.2 119940 40784 pts/1 S+ 18:22 0:00 pdflatex --shell-escape --output-dir=diffout chkoutdir.tex
Then you can pattern match for an entry containing latex and --output-dir, and then capture what comes after the equals sign.
MWE:
\documentclass{article}
\usepackage{fancyvrb}
\usepackage{shellesc}
\begin{document}
\begin{VerbatimOut}{verbfile.txt}
I write that. And that too.
\end{VerbatimOut}
\ShellEscape{bash chkdirscript.sh}
\end{document}
Script:
if ps aux|pcregrep -q "latex.*[-]output-dir=[^ ]+ "; then
OUTDIR=$(ps aux|pcregrep -o1 "latex.*[-]output-dir=([^ ]+) ")
cat $OUTDIR/verbfile.txt
else
cat verbfile.txt
fi
Compiling the LaTeX document will now show the contents of the file in the terminal both in situations where the --output-dir flag is used and in situations where it is not used.
This does not work if the output directory contains spaces. It also may not work if the specified output directory is itself a call to a script or variable of some sort. Furthermore it may not work if there is more than one instance of LaTeX running. So I don't recommend it for actual use, just a proof of concept.