I've knocked out a bash script that uses dialog boxes (Xdialog in this case) to pass arguments to a perfectly good command line utility. The idea is that a rodent-fixated $USER can satisfy his fetish by clicking on a Desktop Icon. [Desktop Icons are those tiny graphic thingies that live under xterms and deface your Megan Gale wallpaper.]

Having punched out said script I suddenly had a Thought. [A Thought is an explosion in the brain that turns very tired hackers into insomniacs.]

What if $USER doesn't have [X|K|G|*]dialog? or has moved or nuked it? [$USER is capable of _anything_.]

My first idea -- to add another dialog box into the script -- seemed to cause a loop. So ..., why not use an xterm? But the "-e" option to xterm seems to have very limited functionality. If I pass a message to an ad hoc xterm it closes immediately because the "-e" option is explicitly designed to terminate the xterm when the command has been executed. Also, "-e" won't allow more than one command -- a "restricted" xterm!? Further, the man page for xterm seems to give just about every option known to mankind, except the one I want.

My "solution", which follows, is a total kludge:
BEGIN SCRIPT SNIPPET <<<<<<<<<<<<

#!/bin/bash
...
TITLE="My Bash Wrapper Script"
XDIAL="/path/to/Xdialog"
...
if [ ! -x "$XDIAL" ]; then
    cat <<- EOF > "/tmp/emergency_script"
        #!/bin/bash

        echo "      $TITLE"
        echo "I can't find the bloody Xdialog file?"
        echo "It may be a permissions problem."
        sleep 3
        EOF
    chmod 700 "/tmp/emergency_script"
    xterm -ut +l +ls +bc -font 10x20 -geometry 40x4 -title "$TITLE" \
        -mesg -e "/tmp/emergency_script"
    rm "/tmp/emergency_script"
    exit 1
fi
...
END SCRIPT SNIPPET <<<<<<<<<<<<<
BTW, "emergency_script" still works if the shebang is absent.

Finally, my question:
What is the correct way to do this? or a better way? or, even, The Debian Way?

TIA,
Robert Thorsby

--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to