If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > key strokes capture in unix

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-15-04, 03:46
rakesh_r_1 rakesh_r_1 is offline
Registered User
 
Join Date: Mar 2004
Location: india
Posts: 2
key strokes capture in unix

i want to capture key strokes into a file.
how to do it.
Reply With Quote
  #2 (permalink)  
Old 03-15-04, 11:02
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
man script
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 03-15-04, 11:32
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
Join Date: Jun 2002
Location: UK
Posts: 525
If you only want to capture keystrokes at a particular time, try adapt the following...

Code:
#!/bin/ksh
echo "Enter password:\c "
char=""; password="";
terminalSettings=$(stty -g)
stty -echo raw # turn off terminal output & canonical mode
return=$(print -n "\r")

while ! ${returnDetected-false}
do
  password=${password}${char}
  char=$(dd bs=1 count=1 2> /dev/null)
  if [ "${char}" != "${return}" ]
  then
    print -n "*"
  else
    returnDetected=true
  fi
done

stty ${terminalSettings} # restore stty settings
echo "\nPassword entered: ${password}"
Reply With Quote
  #4 (permalink)  
Old 03-16-04, 00:51
rakesh_r_1 rakesh_r_1 is offline
Registered User
 
Join Date: Mar 2004
Location: india
Posts: 2
Quote:
Originally posted by aigles
man script
its great
thanks a lot
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On