How to type a dot(.) instead of character?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to type a dot(.) instead of character?
# 1  
Old 04-24-2009
Question How to type a dot(.) instead of character?

Hi,

I want to connect a Oracle databse through unix shell script.
When I will execute a shell script it will ask for user name and password to connect the databsae.
At the time of entering the password field value, it willl display the characters like star(*), dot(.) instead of exact character.

How I will do ?
Please help me because this one urgent to fix in the code .

Regards
Rajesh
# 2  
Old 04-24-2009
Code:
printf "%s" "Please Enter Username:"
read auser

printf "%s" "Please Enter Password:"
stty -echo
read apassword

This suppresses printing of password altogether.
# 3  
Old 04-24-2009
Here is one way of doing what you want. Trick is your version of echo has to support '\c' functionality. Replace the dot with an asterik if that is what you want outputted.
Code:
#!/bin/bash

passwd=""
omodes=`stty -g`

/bin/echo "Enter Password: \c"
while :
do
   stty raw
   c=$(dd bs=1 count=1 2>/dev/null)
   stty -raw

   # break out of loop if CR found
   [[ -z $(echo $c | tr -d "\015") ]] && break

   stty echo
   /bin/echo ".\c"
   passwd=${passwd}${c}
   stty -echo
done

stty $omodes

echo
echo "Password entered: $passwd"

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mv or cp with a . (dot)?

How can I rename a file with a . prefix? I actually need to copy the file but the . seems to be very tough to do. mv ./bla ../fa/la/.bla - doesn't work. I've tried all sorts of bracketing and that doesn't work. Maybe the only way to do it would be to name the file _.bla then rename it... (19 Replies)
Discussion started by: scribling
19 Replies

2. Programming

How to put dot(.) in a string in C?

Hi all, Can anybody please tell me how can I put dot(.) in a string using C programming. for example -- I am having string "10111988" and I want to convert it as "10.11.1988" I will appriciate and thanks in advance.. (4 Replies)
Discussion started by: smartgupta
4 Replies

3. Shell Programming and Scripting

Execution problem ---to remove the lines which starts with one type of character

Hi, I have one file, I need to check if file exist or not and then remove the lines which starts with ? My file1.out data is some thing abcabcppp xyzxyzpqr ????????? ????????? Output should be in test.out abcabcppp xyzxyzpqr I am getting the output as below but the File does not exist... (4 Replies)
Discussion started by: Ramyajiguru1
4 Replies

4. Shell Programming and Scripting

removing DOT by using perl

Hi Friends, I have a variable which has a number (e.g. 12.1234). I want to remove "." (dot) from that number i.e. 121234 I want to do this using perl. Can you please guide me Thank you Anushree (2 Replies)
Discussion started by: anushree.a
2 Replies

5. UNIX for Dummies Questions & Answers

variable name with dot(.)

Hi, Is it possible to declare variable with name having dot(.) in it ? something like gs.test='HELLO' Thanks in advance :) (1 Reply)
Discussion started by: gopalss
1 Replies

6. Programming

array type has incomplete element type

Dear colleagues, One of my friend have a problem with c code. While compiling a c program it displays a message like "array type has incomplete element type". Any body can provide a solution for it. Jaganadh.G (1 Reply)
Discussion started by: jaganadh
1 Replies

7. Shell Programming and Scripting

String type to date type

Can one string type variable changed into the date type variable. (1 Reply)
Discussion started by: rinku
1 Replies

8. Shell Programming and Scripting

dot files

Hi, everyone. I'm now using rsync command, and please tell me what is the wildcard for below looks like. I want to chose dotfiles, such as .ipod .apple but i don't want to chose . and .. ------------------ .* doesn't work, of course. Thanks, Euler04 (2 Replies)
Discussion started by: Euler04
2 Replies
Login or Register to Ask a Question