01-21-2004
Don't apologize. There is nothing wrong with posting a followup to an old thread. The only problem is it would take a book to really answer your question. I'll take a shot at a summary.
The tty driver controls how input lines that you type are delivered to programs. Normally a tty driver will wait until a complete line is available. It also handles stuff like backspace so that program doesn'y need to. The stty command lets you change the way the tty driver works. "stty -a" will display all of the settings. You should do that to see what's available.
"stty -g" displays all of the settings too. But it's encoded and you can't understand the output. But you can save the output and feed it back into the stty command. So:
oldtty=`stty -g`
stty $oldstty
will save and restore the original settings of the tty driver.
stty -canon -echo min 1 time 0
is setting some options in the tty driver. -icanon turns off all special character processing. Now a backspace will be passed to the program rather than being processed. And a carriage return won't terminate a line. So now min and time control when a read has finished. "min 1" says we need at least one character. "time 0" means that we won't wait a while before completing a read. So each read from the program may return after just one character.
the -echo just turns off echo. I would not have done that.
dd is a program that is prepared to read data that is not organized into lines. This dd will read one block (count=1) of data. And that block will be one character in length (size=1). So the dd will read one character and return to the script.
The final echo moves the cursor to the next line.
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I got this from one of my instructors years ago and I use it constantly:
echo "Press any key to continue\c"
oldstty=$(stty -g)
stty -icanon -echo min 1 time 0
dd bs=1 count=1 2>/dev/null
stty "$oldstty" (0 Replies)
Discussion started by: keelba
0 Replies
2. Programming
hello, everyone. I was wondering if anyone could help me out and tell me how to set up the isdigit() (or another way) to ake sure that the input are all digits and not chars. Also, the way my program is set now you need to rerun it in order to renter the data. Is there any way that i can get it to... (1 Reply)
Discussion started by: bebop1111116
1 Replies
3. Shell Programming and Scripting
Did not use 'wait' yet.
How I understand by now the wait works only for child processes, started background.
Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?)
I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies
4. Solaris
My first post.
I need a simple way to log user activity to a unique file for each user and also if any user su's to root, I would like to capture that activity and have it in the unique file for that user. (1 Reply)
Discussion started by: powerrack
1 Replies
5. Shell Programming and Scripting
So I have a weird question for my unix shell script. I wrote a shell script that does several things, but one of the things it does is call an executable. The executable then proceeds to start asking me questions, which it won't proceed until an input is entered. The answer to the questions is... (4 Replies)
Discussion started by: HelpMeProgram
4 Replies
6. Shell Programming and Scripting
Hi,
echo "Enter file name of input file list along with absolute path : "
read inputFileList
if
then
for string in `cat inputFileList`
do
echo $string
done
else
echo " file does not exist"
fi
From the above code, if the user enters a invalid file... (1 Reply)
Discussion started by: i.srini89
1 Replies
7. Shell Programming and Scripting
i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled.
#!/bin/sh
echo " Enter your choice to continue y/Y OR n/N to quit "
read A
if
then
echo " user requested to continue "
##some commands... (7 Replies)
Discussion started by: only4satish
7 Replies
8. Shell Programming and Scripting
Hello.
I am running 2 scripts : script_1 and script_2
These scripts are run as root
Script 2 contains :
#!/bin/bash
#
# ~/bin/script_2
#
E_BAD_PARAM=115
#
date2stamp () {
date --date "$1" +%Y-%m-%d___%H:%M:%S
}
#
USER_NAME=$1
NB_PARAM=$#
PARAM0=$0 (2 Replies)
Discussion started by: jcdole
2 Replies
9. Shell Programming and Scripting
I am trying to allow a user to enter in text and then store that text in a variable $gene to run in an awk command in which those values are used to run some calculations. I am getting syntax errors however, when I try. Thank you :).
The awk runs great if it is a pre-defined file that is used,... (7 Replies)
Discussion started by: cmccabe
7 Replies
LEARN ABOUT DEBIAN
falselogin
FALSELOGIN(1) General Commands Manual FALSELOGIN(1)
NAME
falselogin - a false login shell
SYNOPSIS
/usr/bin/falselogin
DESCRIPTION
falselogin is a small application which can deny the user to log in the system displaying a custom message.
CONFIGURATION
The configuration file for falselogin is /etc/falselogin.conf. Everything you write into this file will be written at login except for some
special strings which will be substituted when they appear in the configuration file. They are:
%mail% string
Number of mail messages in the user's mailbox.
%user% string
Username.
%sysname% string
Sysname from uname. (eg: Linux)
%nodename%, %host% strings
The hostname. (eg: master)
%release% string
Linux kernel version number (eg: 2.0.36)
%version% string
Linux version number (eg: #8 Sun Dec 20 12:02:31 CET 1998)
%machine% string
Machine type (eg: i686)
%debian_version% string
Debian version from /etc/debian_version
PARAMETERS
--wait, -w waitfor
If waitfor is a number, falselogin will sleep waitfor seconds before exiting; if waitfor matches the word 'enter' then falselogin
will wait for the user to input the 'enter' key
AUTHOR
This manual page was written by Tibor Koleszar <t.koleszar@somogy.hu>, for the Debian GNU/Linux system.
FALSELOGIN(1)