Get a list of all possible show commands via bash

I’m trying to write a script that would collect all “possible completions” throughout whole show command tree. When i connect via SSH i can manualy do “show ?” or “show alarm ?” etc… When I try this script locally:
#!/bin/sh { confd_cli <<EOF show ? EOF }

I get a response :
show syntax error: element does not exist

What I’m doing wrong?
Thanks

Regarding “show ?”:

#!/bin/sh
cmd="show"
cmd="${cmd} ?"
len=${#cmd}
ch='\b'
undo="$(printf '%*s' $len | tr ' ' "$ch")"
confd_cli -n <<EOF | sed -e '2d' -e '$d'
$cmd${undo}exit
EOF
exit

Regarding “all possible completions”, if you can use bash instead of sh (2nd row from the bottom is not supported by sh) you can try something like this:

#!/bin/bash
rm -f tmp.txt
cmd="show parser dump show | save tmp.txt"
confd_cli <<EOF
$cmd
exit
EOF
sed -e 's/<[^>]*>//g' tmp.txt > tmp2.txt
while read cmd; do
cmd="${cmd} ?"
len=${#cmd}
ch='\b'
undo="$(printf '%*s' $len | tr ' ' "$ch")"
confd_cli -n <<EOF | sed -e '2d' -e '$d'
$cmd${undo}exit
EOF
done < <(cat tmp2.txt)
exit

I did a very quick test and had no luck.
In the end i did it by hand.
BR