The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
To print a specific line in Shell or awk. tushar_tus Shell Programming and Scripting 4 10-23-2008 01:12 PM
Error while trying to print message Navatha Shell Programming and Scripting 3 10-08-2008 12:54 PM
How to print specific lines with awk Bugenhagen Shell Programming and Scripting 10 08-16-2007 07:41 AM
How to print a specific page randomcz UNIX for Dummies Questions & Answers 3 01-31-2007 03:03 PM
shell specific prompt dranNfly UNIX for Dummies Questions & Answers 3 04-27-2005 09:50 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-10-2008
Niroj Niroj is offline
Registered User
  
 

Join Date: Aug 2008
Location: Bangalore, INDIA
Posts: 55
Print a message at specific line on prompt

Hi Friends,
I am using HP-UNIX(ksh). I want to print a message at specific line on the prompt screen. For Example:

for num in 1 10 3 145
do
echo $num // need to print this on the same line for each number
sleep 2
done

Actual Output:
==========
1
10
3
145

Expected Output:
=============
1 then it will be 10 then 3 and at last 145 (like a electronics stopwatch display)


please suggest me how to do this? can we use tput here?
  #2 (permalink)  
Old 12-10-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,315
You can achieve this with tput. Check the man page of tput.

Regards
  #3 (permalink)  
Old 12-10-2008
yongitz yongitz is offline
Registered User
  
 

Join Date: Apr 2008
Location: Philippines
Posts: 68
How about issuing a clear command before echo? would that help?
  #4 (permalink)  
Old 12-10-2008
Niroj Niroj is offline
Registered User
  
 

Join Date: Aug 2008
Location: Bangalore, INDIA
Posts: 55
Actual problem is how to get the variable cursur point !

Thanks Franklin..

But the actual problem here is to get the cursor position dynamically. The cursor pos is variable and this prog need to get the printing position before printing to that location. Other parts like clearing we can use our own logic. Like ..

====================
for e in asd niroj sinu rajesh ava o
do

l=` expr length $e `
tput cup 30 40#This is varible. I need to get the cursor pos dynamically


while [ $l -ge 0 ] //to clear at position i am overwriting with space double the prev word length
do
print " \c"
l=` expr $l - 1 `
done

tput cup 30 40#This is varible. I need to get the cursor pos dynamically

echo $e
sleep 1

done
  #5 (permalink)  
Old 12-10-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,315
Maybe ncurses is something for you, Google on it.

Regards
  #6 (permalink)  
Old 12-11-2008
Niroj Niroj is offline
Registered User
  
 

Join Date: Aug 2008
Location: Bangalore, INDIA
Posts: 55
Got the solution to get the cursor pos dynamically

Actually this solution I got from a site..

for num in 1 10 3 145
do
tput sc //Save the current cursor position
echo "$num\c"
tput rc //Recover the saved cursor position
sleep 1
tput el //Clears the current line
tput rc
done

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0