I have a simple bash script where I select files to use with an AWK script.
In the selection process I use whiptail.
[https://en.wikibooks.org/wiki/Bash_Shell_Scripting/Whiptail]
I need to port this script to windows.
--> Is there a simple whiptail equivalent in powershell? <--
PS: It is currently running in WSL.
Regards
Holger Erlands-Petersen
Please see the filebrowser part of my bash script and the whiptail menu below:
# ------------------------------------------START Filebrowser() START--------------------------------------------
function Filebrowser()
{
# *** Inspired by Claude Pageau ***
# https://github.com/pageauc/FileBrowser
#
# første parameter er menuens titel.
shopt -s nocaseglob # Skelner ikke mellem store og små bogstaver i filnavne (Windoze).
DIR_LIST=$(ls *.csv -lhp | grep -v / | awk -F ' ' ' { print $9 " " $5 } ') # Viser kun csv filer [filnavn + størrelse].
shopt -u nocaseglob # Slå det fra igen.
# Vælg fil fra liste. Valgt filnavn retur i 'SELECTION':
SELECTION=$(whiptail --title "$1" \
--menu "Pil-op/Pil-ned/Tab <Enter> --> valg\n" 0 0 0 \
--cancel-button Afbryd \
--ok-button Valg $DIR_LIST 3>&1 1>&2 2>&3)
RET=$? # Reurkode. 0 = OK, 1 = Afbryd, 255 = ESC.
if [ $RET -eq 1 ]; then # Har brugeren valgt at afbryde?
return 1 # Afbrudt ved valg
elif [ $RET -eq 255 ] ; then
return 255 # Afbrudt ved ESC.
elif [ $RET -eq 0 ]; then # Brugeren valgte noget (en fil).
if (whiptail --title "Bekræft valg" --yesno "Filnavn: $SELECTION" 7 40 \
--yes-button "Bekræft" \
--no-button "Prøv igen"); then
FILENAME="$SELECTION"
else
Filebrowser "$1" # Brugeren valgte 'Prøv igen'.
fi
else
# Ukendt fejl i valg.
echo $RET
sleep 10
whiptail --title "FEJL: Fejl i valg" \
--msgbox "Fejl ved skift til $SELECTION" 0 0
logthis "Filebrowser: Fejl ved skift til $SELECTION $?"
Filebrowser "$1"
fi
}
# ------------------------------------------END Filebrowser() END--------------------------------------------