Siddhartha Sen
Siddhartha Sen

Reputation: 81

Read from terminal with tty echo

I have this read routine:

proc getUserInput { query } {
    send_user "$query: "
    flush stdout  
    set data [gets stdin]
    send_user "\n"
    return $data
}

This works but does not echo on the tty. How to make the script echo on the tty? This function is called upon a control char trapped in an interact session.

Upvotes: 0

Views: 308

Answers (1)

Siddhartha Sen
Siddhartha Sen

Reputation: 81

Thank You Mr Glen Jackman

I added the line..

exec stty echo

as the first line of the function and the echo was restored.

The new function is:

proc getUserInput { query } {
    exec stty echo
    send_user "$query: "
    flush stdout  
    gets stdin data
    return $data
}

Upvotes: 1

Related Questions