Unix Shell - How to write Full Screen shell script supporting cursor moving up and down?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > June 2006 > How to write Full Screen shell script supporting cursor moving up and down?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to write Full Screen shell script supporting cursor moving up and down?
James

2006-06-07, 1:23 am

Hi all,

I am trying to write a full-screen utility, say modifying new user
account on Linux box:
which displays user attributes: such as UID, username, home dir, login
shell, etc.
Users should be able to move the cursor up and down to modify each user
attribute.
I wondered if I could do it using Korn shell, or I have to implement it
using some kind
of "cursor" library of any advanced programming language.

Thanks,

James

Chris F.A. Johnson

2006-06-07, 1:23 am

On 2006-06-07, James wrote:
> Hi all,
>


> I am trying to write a full-screen utility, say modifying new user
> account on Linux box: which displays user attributes: such as UID,
> username, home dir, login shell, etc.
> Users should be able to move the cursor up and down to modify each user
> attribute.
> I wondered if I could do it using Korn shell, or I have to implement
> it using some kind of "cursor" library of any advanced programming
> language.


See my article at UnixReview.com:
<http://www.unixreview.com/documents...1a/ur0511a.html>.

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
bsh

2006-06-07, 7:23 pm


Chris F.A. Johnson wrote:
> James wrote:
> <http://www.unixreview.com/documents...1a/ur0511a.html>.


Although quite clever, the above treatise gives techniques
and workarounds for a feature which is built in to every
ksh(1), for something as simple as enabling the arrow
keys and command line history. Do a search on "arrow
keys" through C.U.S. for available code, including mine.

=Brian

Chris F.A. Johnson

2006-06-07, 7:23 pm

On 2006-06-07, bsh wrote:
>
> Chris F.A. Johnson wrote:
>
> Although quite clever, the above treatise gives techniques
> and workarounds for a feature which is built in to every
> ksh(1), for something as simple as enabling the arrow
> keys and command line history.


That article has nothing to do with enabling the arrow keys and
command line history, as that is already builtin to most shells.

The article is about using the arrow and function keys in scripts.

> Do a search on "arrow keys" through C.U.S. for available code,
> including mine.


The only articles I found that do anything like my code in the
above URL are by Heiner Steven, and look very much like my
functions. (I may have been influenced by Heiner's functions, which
were written before mine.)

Most of the articles are about using the arrow keys at the command
line, which seems to be a problem for some people using ksh. I've
never had the problem, even in ksh.

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
Stephane Chazelas

2006-06-08, 7:26 am

On Wed, 7 Jun 2006 18:35:30 -0400, Chris F.A. Johnson wrote:
[...]
>
> The only articles I found that do anything like my code in the
> above URL are by Heiner Steven, and look very much like my
> functions. (I may have been influenced by Heiner's functions, which
> were written before mine.)
>
> Most of the articles are about using the arrow keys at the command
> line, which seems to be a problem for some people using ksh. I've
> never had the problem, even in ksh.


See also:

http://groups.google.com/group/comp...35d2f3360adb387
for some POSIX code.

bash and zsh have some builtins to take user input with support
for arrow keys:

read -e var

in recent versions of bash

vared var

in zsh.

You may be able to redefine keys to perform user defined actions.
I don't think bash allows you to define new widgets as zsh does,
so you may be soon limited with bash. Possibilities are endless
with zsh, but I would rather use PERL than a shell to do
anything complex.

--
Stephane
Robert Bonomi

2006-06-08, 1:25 pm

In article <1149643743.776328.78040@f6g2000cwb.googlegroups.com>,
James <jzheng22@gmail.com> wrote:
>Hi all,
>
>I am trying to write a full-screen utility, say modifying new user
>account on Linux box:
>which displays user attributes: such as UID, username, home dir, login
>shell, etc.
>Users should be able to move the cursor up and down to modify each user
>attribute.
>I wondered if I could do it using Korn shell, or I have to implement it
>using some kind
>of "cursor" library of any advanced programming language.


The obvious answer for this is: "use the *right* shell." namely "wsh"

Google will provide you 'more than you want to know' about it, and the
package it's built around "tcl/tk". For "quick-and-dirty" full-screen
and/or GUI, tcl/tk is hard to beat.


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com