08-10-2016
As you are using
bash, did you consider the buitltin
read's -s option:?
man bash:
Quote:
read [-ers] [-u fd] [-t timeout] [-a aname] [-p prompt] [-n nchars] [-d delim] [name ...] .
.
.
-s Silent mode. If input is coming from a terminal, characters are not echoed.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
'Morning
vmstat 1 1|sed 1,2d|awk '{printf("%s\n",$1)}'|read var
echo $var
This syntax run on AIX (ksh) but not on linux (bash).
I think that problem is the read command, because the following syntax is ok :
vmstat 1 1|sed 1,2d|awk '{printf("%s\n",$1)}'
Could someone help me!
regards... (16 Replies)
Discussion started by: nymus7
16 Replies
2. Shell Programming and Scripting
I have file which is space filled likE below
Note: here spaces are replaced by |.
When I use read command to read this file all the spaces are truncated only the default space is not removed. The output is
Note: here spaces are replaced by |.
Can this default truncation be override? (4 Replies)
Discussion started by: COD
4 Replies
3. Shell Programming and Scripting
Hi all,
What does -u option indicates in read command.
while read -u var1
do
.
.
done < file.txt (1 Reply)
Discussion started by: krishna_gnv
1 Replies
4. Shell Programming and Scripting
hi all
iam not able use read command in the while loop in the following program
while read line
do
echo $line
echo "enter name"
read name
echo "your have entered $name"
done < work.txt
THE READ COMMAND INSIDE THE WHILE LOOP IS NOT WORKING, IS ANY OTHER WAY TO SOLVE THIS... (7 Replies)
Discussion started by: avi.skynet
7 Replies
5. Shell Programming and Scripting
Is there a way to use the READ command and force the user to enter a non-zero length string? If the user enters a zero length string the user input is rejected.
code:
print "what is the answer: \n"
read answer (2 Replies)
Discussion started by: djehresmann
2 Replies
6. UNIX for Dummies Questions & Answers
Hi everyone,
I have problem while writing a shell script for linux (Red Hat).
First I need to create a read command. I tried to google this but so far I can't sort this out. I hope you will be able to help me.
I have to read a file like this :
GESTION_DATA_SET_variable1_variable2
... (2 Replies)
Discussion started by: Aswex
2 Replies
7. UNIX for Dummies Questions & Answers
Hey, guys!
Trying to research this is such a pain since the read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword. :eek:
So, I wanted to use a command statement similar to the following.
This is kinda taken... (2 Replies)
Discussion started by: ProGrammar
2 Replies
8. Shell Programming and Scripting
Hello guys,
I am trying to a script that reads from key board and use the entered value in the next step.
Example: enter folder name
read $folder (i will give work)
cd /main/$folder/
pwd
it should print /main/work
---------- Post updated at 03:31 PM ----------... (1 Reply)
Discussion started by: sharath24
1 Replies
9. Shell Programming and Scripting
Hi,
I am facing issues with the below:
I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,).
Now i want to read this command from file and execute it.
So my code below is :
Contents in the lookup.lkp file is :
c_e,m,a,`cd $BOX | ls cef_*|tail... (7 Replies)
Discussion started by: vital_parsley
7 Replies
10. UNIX for Beginners Questions & Answers
Trying to use the read command. How do you add a 2nd option? In this example I'd like to offer two options, pre and post. If you answer pre, you get one output but if you answer post, you get another output.
echo Is this pre or post?
read pre
if
then echo You have typed pre.
fi (6 Replies)
Discussion started by: jimmyf
6 Replies
read(n) Tcl Built-In Commands read(n)
__________________________________________________________________________________________________________________________________________________
NAME
read - Read from a channel
SYNOPSIS
read ?-nonewline? channelId
read channelId numChars
_________________________________________________________________
DESCRIPTION
In the first form, the read command reads all of the data from channelId up to the end of the file. If the -nonewline switch is specified
then the last character of the file is discarded if it is a newline. In the second form, the extra argument specifies how many characters
to read. Exactly that many characters will be read and returned, unless there are fewer than numChars left in the file; in this case all
the remaining characters are returned. If the channel is configured to use a multi-byte encoding, then the number of characters read may
not be the same as the number of bytes read.
ChannelId must be an identifier for an open channel such as the Tcl standard input channel (stdin), the return value from an invocation of
open or socket, or the result of a channel creation command provided by a Tcl extension. The channel must have been opened for input.
If channelId is in nonblocking mode, the command may not read as many characters as requested: once all available input has been read, the
command will return the data that is available rather than blocking for more input. If the channel is configured to use a multi-byte
encoding, then there may actually be some bytes remaining in the internal buffers that do not form a complete character. These bytes will
not be returned until a complete character is available or end-of-file is reached. The -nonewline switch is ignored if the command returns
before reaching the end of the file.
Read translates end-of-line sequences in the input into newline characters according to the -translation option for the channel. See the
fconfigure manual entry for a discussion on ways in which fconfigure will alter input.
USE WITH SERIAL PORTS
For most applications a channel connected to a serial port should be configured to be nonblocking: fconfigure channelId -blocking 0. Then
read behaves much like described above. Care must be taken when using read on blocking serial ports:
read channelId numChars
In this form read blocks until numChars have been received from the serial port.
read channelId
In this form read blocks until the reception of the end-of-file character, see fconfigure -eofchar. If there no end-of-file charac-
ter has been configured for the channel, then read will block forever.
EXAMPLE
This example code reads a file all at once, and splits it into a list, with each line in the file corresponding to an element in the list:
set fl [open /proc/meminfo]
set data [read $fl]
close $fl
set lines [split $data
]
SEE ALSO
file(n), eof(n), fblocked(n), fconfigure(n), Tcl_StandardChannels(3)
KEYWORDS
blocking, channel, end of line, end of file, nonblocking, read, translation, encoding
Tcl 8.1 read(n)