On 4/20/06, ray hammond <[EMAIL PROTECTED]> wrote:
> I've just installed the new version 1.2.1.5, as stated the read problems
> fixed, although "tput cup 8 38" seems to miss the target.
I just tried this, and the only problem I see in 1.21.5 is that the
read builtin overwrites the 'Select Option...' bit, since in fish, the
read builtin displays a full prompt. The way to fix this is to Specify
the 'Select' bit as a the prompt for 'read'. Replace:
echo 'Select Option [1 - 5 or x to Return] :'
tput cup 8 38
read menu
with:
read -p 'echo "Select Option [1 - 5 or x to Return] : "'
Another sidenote: Fish ships with a small utility called 'set_color',
used to set terminal colors. I find it easier to remember 'set_color
--bold --background=green red' than the various tput options to do the
same thing. Using set_color, you could change the prompt to:
read -p 'printf "Select Option [%s1 - 5%s or %sx%s to return]: "
(set_color --bold) (set_color normal) (set_color --bold) (set_color
normal)' menu
>
> -----Original Message-----
> From: ray hammond [mailto:[EMAIL PROTECTED]
> Sent: 19 April 2006 22:54
> To: 'Axel Liljencrantz'
> Cc: '[email protected]'
> Subject: RE: [Fish-users] tput commands
>
> The cursor is in the wrong position, my mistake. I removed a couple of echo
> lines to neaten the script before I emailed it, hence I messed up the tput
> positioning.
>
> The reverse video is correct, according to the tput man page this is bold
> on/off, I guess in depends of the terminals capabilities.
>
> The script I attached yesterday only ran under a bash shell.
> As I had implicitly specified /bin/sh on line 1.
>
> I have altered the script today to make it run under fish.
>
> --------------Start ------------------------
>
> #!/usr/bin/fish
>
> if test "$OPSYSTEM" = "TANDEM";
> set VIEWER "more"
> else
> set VIEWER "less"
> end
>
> set menu ""
>
> while test "$menu" != "x";
>
> tput clear
> tput smso
> echo 'Sample menu'
> tput rmso
> echo '1. Show disk space'
> echo '2. Show uptime'
> echo '3. Show /var/log/messages'
> echo '4. Show /etc/hosts'
> echo '5. Show network configuration'
> echo 'x. Exit to shell'
> echo ''
> echo 'Select Option [1 - 5 or x to Return] :'
> tput cup 8 38
>
> read menu
>
> tput clear
>
> switch $menu
> case 1
> df -H
> case 2
> uptime
> case 3
> tail /var/log/messages
> case 4
> cat /etc/hosts | $VIEWER
> case 5
> ifconfig | $VIEWER
> end
>
> echo '** Press <ENTER> **'
>
> set press ""
> read press
>
> end
>
> --------------End ------------------------
>
> Running the script seems to start an infinite loop, instead of stopping to
> acquire the users input, the menu gets printed time after time.
> I cannot tell if the tput cursor position line works correctly.
> Have I got something wrong?
>
> -----Original Message-----
> From: Axel Liljencrantz [mailto:[EMAIL PROTECTED]
> Sent: 19 April 2006 10:06
> To: ray hammond
> Cc: [email protected]
> Subject: Re: [Fish-users] tput commands
>
> On 4/18/06, ray hammond <[EMAIL PROTECTED]> wrote:
> > Here is a sample script
> >
> > --------------Start ------------------------
> > #!/bin/sh
> >
> > if test "$OPSYSTEM" = "TANDEM"
> > then
> > VIEWER="more"
> > else
> > VIEWER="less"
> > fi
> >
> > menu=""
> >
> > while test "$menu" != "x"
> > do
> >
> > tput clear
> > tput smso
> > echo 'Sample menu'
> > tput rmso
> > echo '1. Show disk space'
> > echo '2. Show uptime'
> > echo '3. Show /var/log/messages'
> > echo '4. Show /etc/hosts'
> > echo '5. Show network configuration'
> > echo 'x. Exit to shell'
> > echo ''
> > echo 'Select Option [1 - 5 or x to Return] :'
> > tput cup 10 38
> >
> > read menu
> >
> > tput clear
> >
> > case $menu in
> >
> > '1')
> > df -H
> > ;;
> >
> > '2')
> > uptime
> > ;;
> >
> > '3')
> > tail /var/log/messages
> > ;;
> >
> >
> > '4')
> > cat /etc/hosts | $VIEWER
> > ;;
> >
> > '5')
> > ifconfig | $VIEWER
> > ;;
> >
> > esac
> >
> > echo '** Press <ENTER> **'
> > read press
> > done
> >
> > --------------End ------------------------
> >
> > To use the menu create a file call menu.sh and paste the above in.
> > Save the file, using chmod add the execute permission. Run the script.
> >
> > It should display a menu of 5 options. The header should be printed in
> > bold. The cursor should be placed after the statement
> > "'Select Option [1 - 5 or x to Return] :".
>
> This works for me, except that the cursor is placed two lines below
> the specified option. But that is as it should be, it is placed on
> line 10 as per the tput command. Also, my terminal doesn't bold the
> menu, it reverses the video, but smso only specifies 'standout mode'.
>
> Is it the case that this does not work on your system when the command
> is started from fish, but it does work when started from bash? If so,
> try adding a 'reset' command at the top. If this helps, fish must
> leave your terminal in a wonky state on startup.
>
> --
> Axel
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.385 / Virus Database: 268.4.4/318 - Release Date: 18/04/2006
>
>
>
--
Axel
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users