Shell avec dialog et Xdialog.

From Tuxunix
Jump to: navigation, search
   1.#!/bin/sh
   2.       
   3.DIALOG=${DIALOG=dialog}
   4.     
   5.$DIALOG --title "tuxedo dialog/bash" --clear\
   6.     --yesno "Hello, this is a good test or not?" 8 50
   7.       
   8.case $? in
   9.      0) echo "Oui."
  10.      ;;
  11.      1) echo "Non."
  12.      ;;
  13.      *) echo "Appuye sur Echap."
  14.      ;;
  15. esac

Dialog1.gif

   1.#!/bin/sh
   2.       
   3.DIALOG=${DIALOG=Xdialog}
   4.       
   5.$DIALOG --title "tuxedo dialog/bash" --clear\
   6.      --yesno "Hello, this is a good test or not?" 8 50
   7.       
   8.case $? in
   9.     0) echo "Oui."
  10.     ;;
  11.     1) echo "Non."
  12.     ;;
  13.     *) echo "Appuye sur Echap."
  14.     ;;
  15.esac


Dialog2.gif

   1.#!/bin/sh
   2.DIALOG=${DIALOG=dialog}
   3.tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
   4.trap "rm -f $tempfile" 0 1 2 5 15
   5.       
   6.$DIALOG --clear --help-button --item-help --title "MENU BOX" \
   7.    --menu "Hi, this is a menu box. You can use this to \n\
   8.      Choose the OS you like:" 20 51 4 \
   9.      "Linux" "The Great Unix Clone for 386/486" "Why use Linux?" \
  10.      "NetBSD" "Another free Unix Clone for 386/486 " "Or NetBSD?" \
  11.      "OS/2" "IBM OS/2 " "aka \"Warp\"" \
  12.      "WIN NT" "Microsoft Windows NT" "hmm" \
  13.      "PCDOS" "IBM PC DOS " "clone of a clone" \
  14.      "MSDOS" "Microsoft DOS " "DOS: Disk Operating System" 2> $tempfile
  15.       
  16.retval=$?
  17.       
  18.choice=`cat $tempfile`
  19.       
  20.case $retval in
  21.      0)
  22.      echo "$choice chosen.";;
  23.      1)
  24.      echo "Cancel pressed.";;
  25.      255)
  26.      echo "ESC pressed.";;
  27.      esac

Dialog3.gif

   1.#!/bin/sh
   2.DIALOG=${DIALOG=Xdialog}
   3.tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
   4.trap "rm -f $tempfile" 0 1 2 5 15
   5.       
   6.$DIALOG --clear --help-button --item-help --title "MENU BOX" \
   7.      --menu "Hi, this is a menu box. You can use this to \n\
   8.      Choose the OS you like:" 20 51 4 \
   9.      "Linux" "The Great Unix Clone for 386/486" "Why use Linux?" \
  10.      "NetBSD" "Another free Unix Clone for 386/486 " "Or NetBSD?" \
  11.      "OS/2" "IBM OS/2 " "aka \"Warp\"" \
  12.      "WIN NT" "Microsoft Windows NT " "hmm" \
  13.      "PCDOS" "IBM PC DOS " "clone of a clone" \
  14.      "MSDOS" "Microsoft DOS" "DOS: Disk Operating System" 2> $tempfile
  15.       
  16.retval=$?
  17.       
  18.choice=`cat $tempfile`
  19.       
  20.case $retval in
  21.      0)
  22.      echo "$choice chosen.";;
  23.      1)
  24.      echo "Cancel pressed.";;
  25.      255)
  26.      echo "ESC pressed.";;
  27.esac

Dialog4.gif