Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Location
    india
    Posts
    2

    Unanswered: key strokes capture in unix

    i want to capture key strokes into a file.
    how to do it.

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    man script
    Jean-Pierre.

  3. #3
    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}"

  4. #4
    Join Date
    Mar 2004
    Location
    india
    Posts
    2
    Originally posted by aigles
    man script
    its great
    thanks a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •