Is there a way to use inputbox and enter multiple lines?

3

1

I want to have a simple way to enter messages for employees to see upon logging in. It doesn't have to be date specific, although that would be nice, but I can't find a way to use dialog to allow me to enter multiple lines of text before I cat to the file.

Little help?

#!/bin/sh
DIALOG=${DIALOG=dialog}
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --title "Bulletin Board Entry" --clear \
        --inputbox "Enter Today's Very Important\n
employee information below:" 16 51 2> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
  cat $tempfile
else
  echo "ESC pressed."
fi
;;
esac

Robby Glasco

Posted 2012-07-12T16:12:20.500

Reputation: 31

Answers

0

Use --editbox emptyfile instead of --inputbox. Unfortunately this won't allow you to pass /dev/null instead of emptyfile, so you'll actually have to create an empty (temporary) file. Or a file containing a message template.

MvG

Posted 2012-07-12T16:12:20.500

Reputation: 1 259

I'm on redhat RHEL5 and I don't have editbox available. Any workaround? – Robby Glasco – 2012-07-18T15:17:59.673

You could grab the latest sources from the dialog homepage, compile them yourself and call them by explicit path for this invocation. Unless you want to install this latest version system-wide.

– MvG – 2012-07-18T15:24:47.747

0

As an alternative to dialog, you could simply fire up an editor with the temporary file. That way, every user might even be able to use his or her preferred $EDITOR, instead of the feature-limited dialog. Many applications do this kind of thing when they want user input. Version control systems in particular come to my mind here.

MvG

Posted 2012-07-12T16:12:20.500

Reputation: 1 259