cursor positioning

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cursor positioning
# 1  
Old 08-05-2009
cursor positioning

Hi All,

please help me to know how to move the cursor to the desired position?

For example, in a shell script, I am displaying
echo "\t Enter your Name:"

please help me how to move cursor near the first word.

for example, if the output is as below
Enter your name:
(I want the cursor to be blinking here)

I have tried tput command. please help me..

Thankyou all in advance... Smilie
# 2  
Old 08-05-2009
jb>cat s1
echo " Enter your Name:"
read name
jb>sh s1
 Enter your Name:
jb>cat s2
printf " Enter your Name:"
read name
jb>sh s2
 Enter your Name:myname

# 3  
Old 08-05-2009
With bash :
$ read -p "Enter your text: " var
Enter your text: sssssss
$ echo $var

With ksh :
$ read var?"Enter your text: "
Enter your text: sssss
$ echo $var

# 4  
Old 08-05-2009
I'm not sure what you are trying, but here is some method howto make something.
#!/bin/ksh # or bash
# howto handle default value = user press return, nothing else
echo -e "Remove: (y/n): y\b\c"
read str
[ "$str" != "" ] && answer="$str"

# write something and make carriage return
echo -e "Your name\r\c"
read name

# write and remove
echo -e "Some\r\c"
sleep 2
echo -e "    \r\c"
sleep 1
echo -e "More\r\c"
sleep 1

echo -e "Cnt: \c"
while ((i<30))
     echo -e "$i\b\b\c"
     (( i+=1 ))
     sleep 1

Using cursor something like:
cat <<EOF
Screen test

loc0_0=$(tput cup 0 0)
bold=$(tput  smso)
boldoff=$(tput rmso)
save_loc=$(tput sc)
ret_loc=$(tput rc)

# after this init, use variable
echo "${bold}BoldText${boldoff} and not so bold"
echo -e "(Look line 0) Ask here:${save_loc}${loc0_0}LOCATION 0,0 IS HERE ***************${ret_loc}\c"
read answer
echo "${save_loc}${loc0_0}Your answer:$answer   ${ret_loc}"
echo "look line 0"

---------- Post updated at 08:49 PM ---------- Previous update was at 08:20 PM ----------

More info
man tput
man 5 terminfo

Last edited by kshji; 08-05-2009 at 03:48 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Complex positioning

I got these entries in a file alias'ssh ' alias'ssh user2 @' alias'ssh user3@' In the above lines, last line is the correct format. The first is IP@username, has got a space after the... (9 Replies)
Discussion started by: anil510
9 Replies

2. UNIX for Dummies Questions & Answers

positioning words in a line

I have problem with this for last few days and I would really be grateful if you can help me :wall::wall::wall::wall::wall: I have sets of files in one directory, and each of them have few lines each one of these lines has 1 or more occurrence of words Y = I need to find the position of the... (10 Replies)
Discussion started by: A-V
10 Replies

3. UNIX and Linux Applications

Passing the value of a cursor to another cursor

i have 2 cursors. i want to assign the value of first cursor(employee_id) to the where condition of cursor c2(please refer the bold statement). how do i do if i want to assign the value of c1 to where condition of cursor c2? declare cursor c1 IS select employee_id from employee cursor c2... (1 Reply)
Discussion started by: vkca
1 Replies

4. Shell Programming and Scripting

Tab positioning

xx00102 1(SG): xx00102 3(SG): xx00115 lan900: xx00115 lan901: xx00116 1(SG): xx00116 3(SG): the boxes are echoed on the same line with one \t. Is there anyway to get all the boxes to line up? Or possibly is there a way to fix the position of something... (3 Replies)
Discussion started by: trimike
3 Replies

5. UNIX for Dummies Questions & Answers

Mouse clicking/positioning in Terminal

Is is possible to use the mouse in Terminal on OS X Leopard? I thought I read somewhere in the book that I have that it is, but I can't find it. I'd like to use it to click in one of the editors if I have to. (0 Replies)
Discussion started by: Straitsfan
0 Replies

6. Programming

positioning cursor

I am using curses.h and signals.h to control output to screen. My code displays an unchanging prompt that waits for user input. Meanwhile alarm signals are being generated that cause other ancillary messages to appear at other locations on the screen at various times. The problem I have is with... (2 Replies)
Discussion started by: enuenu
2 Replies

7. UNIX for Dummies Questions & Answers

Cursor Positioning

Can anyone tell me how to ouput the current cursor coordinate? I have tried using tput sc and tput rc. However I want to know what the coordinate is. Thanks. (1 Reply)
Discussion started by: bestbuyernc
1 Replies

8. UNIX for Dummies Questions & Answers

Positioning curser at EOF in vi

Hi there, Is there a way to position the cursor at EOF in vi, I know from the man pages how to position the cursor at the end of a paragraph, but what about the EOF (End Of File). Regards (6 Replies)
Discussion started by: JimJim
6 Replies

9. UNIX for Dummies Questions & Answers

Cursor positioning thru VI Editor

Is there a way that I can position cursor at say line 23, column 2? Thank you in advance. (8 Replies)
Discussion started by: Latha Nair
8 Replies
Login or Register to Ask a Question