Re: How To Spice Up Menus in Bash

From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 06/08/05


Date: Wed, 8 Jun 2005 16:33:22 -0400

On 2005-06-07, dfrench@mtxia.com wrote:
>
> Chris F.A. Johnson wrote:
>> On 2005-06-06, dfrench@mtxia.com wrote:
>> > googlemike@hotpop.com wrote:
>> >> Anyone out there use Suse's Yast tool from command line? I want to
>> >> create some simple command line tools for adding users into a database,
>> >> but want to spice it up a little like Yast. Moreover, I want to keep
>> >> this really, really simple by using Bash. Is there a program I can
>> >> download that lets me create scripts in Bash to give me a Yast-like
>> >> experience? Also, you Novell-heads out there (said nicely -- I once was
>> >> a CNE) you may remember the Novell command line text GUI (TUI)
>> >> environment that is similar to Yast.
>> >>
>> >> Anyone got an answer? Much appreciated. Thanks.
>> >
>> > There is always the old reliable shell curses and French menus shell
>> > function libraries:
>> >
>> > http://dfrench.tripod.com/curses.txt
>> > http://dfrench.tripod.com/ksh93curses.txt
>> >
>> > The ksh93 may or may not work with bash, I haven't tried it, however
>> > the bourne shell version (curses.txt) certainly will work.
>>
>> I have never been able to get either one to work with bash -- or
>> ksh93. I've tried on FreeBSD as well as Linux.
>
> Is there an error displayed? If you would, please try it again,
> capture the results and send them to me so I can fix it.

    I may have been a little sweeping with my statement. However,
    neither will work with some of the OSs I use:

         SunOS 4.1 does not have tput.

         In FreeBSD and NetBSD, tput uses termcap names rather than
         terminfo names (or is it the other way round?). The BSD
         equivalent of "tput cup" is "tput cm", but it doesn't produce
         a template when called without arguments.

    That leaves Linux (at the moment, I'm using Ubuntu).

    Running this script:

. curses.sh
initscr
# example useage follows
move 10 10
clrtoeol
addstr "Hello World!!!"
refresh
endwin

    ...produces:

/usr/local/bin/curses.sh: line 102: domainname: command not found

    Otherwise, it seems to work.

$ ./rundemo.sh
./demo.sh[50]: domainname: not found
./demo.sh[50]: 1 \* 2 : unexpected `\'
./demo.sh[50]: 1 \* 2 + 6 : unexpected `\'
./demo.sh[50]: 1 \* 2 : unexpected `\'
./demo.sh[50]: 1 \* 2 + 6 : unexpected `\'
./demo.sh[50]: 1 \* 2 : unexpected `\'
./demo.sh[50]: 1 \* 2 + 6 : unexpected `\'
./demo.sh[50]: 1 \* 2 : unexpected `\'
./demo.sh[50]: 1 \* 2 + 6 : unexpected `\'
./demo.sh[50]: 1 \* 2 : unexpected `\'

   ...ad infinitum (while continually flashing in reverse at the top
   of the screen):

PGMdemo Communications Control System chris@xword
SCR Written by Dana French (dfrench@vialink.com) 06/08/05

$ pwd
/home/chris/work/curses/ksh93
$ ./rundemo.sh
bash: ./rundemo.sh: /usr/dt/bin/dtksh: bad interpreter: No such file or directory

-- 
    Chris F.A. Johnson                     <http://cfaj.freeshell.org>
    ==================================================================
    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
    <http://www.torfree.net/~chris/books/cfaj/ssr.html>