1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#!/bin/sh
# sample-script delivered with sel
#
# if you want to test this script without having installed sel to
# /usr/local/bin, do the following:
# - compile sel, but don't "make install"
# - change lines 18 + 22: sel => ./sel
#
# Thomas Kluge <thomas@darkstar.rhein-neckar.de>
titel="sel sample script"
tmpfile=/tmp/sel-sample.$$
pause() {
echo "Hit any key to continue"
read taste
}
sel_exec() {
sel -b "Select file, please" -q -c "less"
}
sel_file() {
sel -b "Select file, please" -f -q -c "echo % >"$tmpfile
input=$(cat $tmpfile)
rm $tmpfile
dialog --msgbox "You selected: "$input 6 70
}
quit()
{
if [ -f $tmpfile ]; then
rm $tmpfile
fi
exit
}
menu()
{
while true
do
dialog --clear \
--title "What do you want to do today?" \
--menu "$titel" 10 40 3 \
'1' 'Execute command (less) by sel' \
'2' 'Read result via tempfile' \
'0' 'Exit' \
2> $tmpfile
ergebnis=$?
menue=$(cat $tmpfile)
rm $tmpfile
setterm -clear
case "$menue" in
1 ) sel_exec;;
2 ) sel_file;;
0 ) quit;;
esac
done
}
menu
# not reached
|