aquaballoon

sh - tempfile

Nov 30th, 2011
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  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. trap 'remove' 0 1 2 5 15
  6.  
  7. remove ()
  8. {
  9. echo "Caught SIGINT ..."
  10. rm -f $tempfile
  11. }
  12.  
  13. $DIALOG --title "My input box" --clear \
  14.         --inputbox "Hi, this is a sample input box\n
  15. Try entering your name below:" 16 51 2> $tempfile
  16.  
  17. retval=$?
  18.  
  19. case $retval in
  20.   0)
  21.     echo "Input string is `cat $tempfile`";;
  22.   1)
  23.     echo "Cancel pressed.";;
  24.   255)
  25.     if test -s $tempfile ; then
  26.       cat $tempfile
  27.     else
  28.       echo "ESC pressed."
  29.     fi
  30.     ;;
  31. esac
Advertisement
Add Comment
Please, Sign In to add comment