For example, getting the title of `konsole` window current interactive `bash` instance is running in:

 #!/bin/bash

 pppid=`ps -o ppid= -p $PPID`
 echo "pppid: $pppid"
 
 wid=`xdotool search --pid $pppid`
 echo "wid: $wid"
 
 title=`xdotool getwindowname $wid`
 echo "title: $title"