Clearing part of screen in Korn Shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Clearing part of screen in Korn Shell
# 1  
Old 11-14-2011
Clearing part of screen in Korn Shell

Hi,
I am writing a menu driven Korn script where I am getting some input from the users (host details, like Hostname, HBA WWN, Devices etc...). I face a challenge when the number of input lines goes past my window size. For this reason, I am planning to use a part of the screen for user input, say from Row 30-40 with "tput cup 30 20 ". This way, I can get the user input for one host at a time and display only important information. Now, how do I clear the screen only from Row 30 to 40 for the next entry?
I tried something like tput cup 30 20 clear, but that doesn't work. I anyone has a script or know a way to do this, please share your knowledge. Your help is really appreciated.
# 2  
Old 11-14-2011
You can use tput el to clear from current position to end of line.

So to define $CLEAR_HOST to clear a block from 30,10 to 40,10 you could do:

Code:
CL=$(tput el)
L=30
while [ $L -le 40 ]
do
    CLEAR_HOST="$CLEAR_HOST$(tput cup $L 10)$CL"
    let L=L+1
done

The just do printf "%s" $CLEAR_HOST whenever you want to clear the HOSt entry area.
# 3  
Old 11-15-2011
You might also consider using the Shell CURSES library. See Shell Curses function library.
# 4  
Old 11-21-2011
Thanks for clue, Chubler ..... "tput ed" is what I was looking for.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Clear specific part of the screen

I want to clear specific part of the screen. Say for example , i am running a bash script for i in {1..100} do echo "Current Record = $i" done if i use a clear command over there , it will clear my screen however when i scroll up i would have the old records , is there anyway in unix to... (5 Replies)
Discussion started by: chidori
5 Replies

2. Shell Programming and Scripting

Help related to clearing of shell scripting doubt

Hello Gurus, Can anybody please help me to understand as what does this lines(Marked in bold) does: _TABLESPACE_OFFLINE=`cat ${_tmp_res} | grep -iv "online" | grep -v "^*$" | grep -iv "SQL>"` ------->1 if ;then _tmp_tablespace_status=1 ... (1 Reply)
Discussion started by: hitesh1907
1 Replies

3. Shell Programming and Scripting

Clearing leading and trailing blanks from a string in C Shell

Does anyone know of a way with C Shell that will work on both Linux and Sun to clear all leading and trailing blanks from a previously specified string? I am using the following code to replace blanks with underscores: set Company = `echo $Company | sed 's/ /_/g but I don't want any... (1 Reply)
Discussion started by: phudgens
1 Replies

4. Shell Programming and Scripting

Bourne shell & Korn shell

Could some one tell me the difference btw Bourne shell and the Kshell? Which is more flexible and reliable in terms of portability and efficiency. When i type the following command .. $ echo $SHELL yields me /bin/sh Does this tells me that I am in Bourne shell. If yes, how can i get... (6 Replies)
Discussion started by: bobby1015
6 Replies

5. Shell Programming and Scripting

How to activate Korn Shell functionnalities in Bourne Shell

Hi All I have writing a Korn Shell script to execute it on many of our servers. But some servers don't have Korn Shell installed, they use Borne Shell. Some operations like calculation don't work : cat ${file1} | tail -$((${num1}-${num2})) > ${file2} Is it possible to activate Korn Shell... (3 Replies)
Discussion started by: madmat
3 Replies

6. UNIX for Advanced & Expert Users

How to disable the clearing of the first page when executing screen tool

Hi Guy, In order to monitor the user sessions, I have put the screen tool in the .profile in order to record the whole session. However, when the user logs in, the screen command is executed and the screen is first cleared, then the command prompt appears. so, I basically want to disable the... (2 Replies)
Discussion started by: saad26
2 Replies

7. Programming

Clearing screen in Python using curses?

Hi guys, I've got the following code for clearing the screen in my Python shell using curses: import curses scrn = curses.initscr() scrn.clear() However, upon execution, my shell crashes. Would appreciate a pointer in the right direction. Thanks. :D (4 Replies)
Discussion started by: sadistik_exec
4 Replies

8. Shell Programming and Scripting

how to convert from korn shell to normal shell with this code?

well i have this code here..and it works fine in kornshell.. #!/bin/ksh home=c:/..../ input=$1 sed '1,3d' $input > $1.out line="" cat $1.out | while read a do line="$line $a" done echo $line > $1 rm $1.out however...now i want it just in normal sh mode..how to convert this?... (21 Replies)
Discussion started by: forevercalz
21 Replies

9. Shell Programming and Scripting

KORN Shell - Spawn new shell with commands

I want to be able to run a script on one server, that will spawn another shell which runs some commands on another server.. I have seen some code that may help - but I cant get it working as below: spawn /usr/bin/ksh send "telnet x <port_no>\r" expect "Enter command: " send "LOGIN:x:x;... (2 Replies)
Discussion started by: frustrated1
2 Replies

10. Shell Programming and Scripting

PERL: clearing the screen

I would like to clear the screen in perl scripts without having to use system(). Is there a way to do this? (7 Replies)
Discussion started by: dangral
7 Replies
Login or Register to Ask a Question