1

I made my own UNIX shell script that runs at boot that helps me mount/unmount USB drives. I use the dialog package for my interface.

The code works fine when I run it normally but on boot the dialog menu acts strange. When I press keys on the keyboard to navigate the dialog it prints the actual key on the line instead of changing the focus on the option.

Also, the shell is kept in /etc/init.d/ and it runs several other scripts in /opt/boot/ (NOTE: script at bottom of question)

dialog

Any quick fixes for this?

$ cat > run
#
#Harry's System
#
title="Harry's Boot System"
echo -e "[ \033[32mok\033[39m ] Starting: $title"
if dpkg -s dialog
then
    echo -e "[ \033[32mok\033[39m ] Packages good."
    pkgs=0
else
    echo -e "[ \033[31merr\033[39m ] Packages bad, installing new."
    apt-get install dialog
    pkgs=1
fi
dialog --backtitle "$title" --title "Main Menu" --menu "Select a shell script to run..." 15 60 2 Mount_USB_Drive "Mounts all USB drives." Un-Mount_USB_Drive "Un-mounts all USB drives." 2>/tmp/menuitem.$$
menuitem=`cat /tmp/menuitem.$$`
opt=$?
echo "---$opt---"
echo "---$menuitem---"
case $menuitem in
    Mount_USB_Drive) echo "mntUSB"
    /opt/boot/usb.sh
    ;;
    Un-Mount_USB_Drive) echo "umntUSB"
    /opt/boot/un-mount_usb.sh
    ;;
esac
rm /tmp/menuitem.$$
echo -e "[ \033[32mok\033[39m ] END"
echo -e "\033[39m"
clear
  • We are going to need to see the scripts and the permissions on them. Also, why are you mounting drives this way? – Steve Robillard Feb 13 '15 at 2:03
  • @SteveRobillard On it! – Harry Saliba Feb 13 '15 at 2:10
  • I used another question on this stack-exchange for a tutorial on the boot script. I believe I used chmod 755 run.sh – Harry Saliba Feb 13 '15 at 2:17
  • What happens if you use the TAB, ENTER and SPACE keys. And what are you trying to accomplish with this? – Steve Robillard Feb 13 '15 at 2:42
  • @SteveRobillard tab and space do the same and enter continues. i found if i pressed the correct keys and pressed enter it worked but the highlight won't change and the text continues to show up. This question is not about what i'm doing it's about the problem i am having with the menu. – Harry Saliba Feb 13 '15 at 2:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.