![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ls while read loop - internal read picking up wrong input | dkieran | Shell Programming and Scripting | 2 | 05-14-2007 03:02 PM |
| about READ...please help! | fiol73 | UNIX for Dummies Questions & Answers | 1 | 12-28-2006 09:23 PM |
| Cannot read in variable using read on first try | normie | UNIX for Advanced & Expert Users | 1 | 10-05-2005 01:42 AM |
| read line and read next | ariuscy | UNIX for Dummies Questions & Answers | 7 | 09-21-2005 07:04 AM |
| drw-r--rw- Not able to read | rs_reddy | HP-UX | 3 | 11-16-2003 06:05 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
read is not pausing to read
Can anyone tell me why this section of my script doesn't work? The script is designed to accept piped data, store it in a temporary location, and then prompt the user for their user name. It doesn't stop to read the username, however. It just finishes.
It is called like: Code:
cat datafile | myscript Code:
datafile1="data$$.dat" datafile2="data$$2.dat" pdffile="pdf$$.pdf" # Store piped data cat > $datafile1 # Prompt for username echo "Enter your username:" # Read username read username Code:
# Store piped data
cat > $datafile1
while [ -z username ]
do
read username
done
# Prompt for username
echo "Enter your username:"
# Read username
read username
|
|
||||
|
Just to expand on the answer a little bit, when you pipe something to a command, the shell changes the input file descriptor so the command is no longer reading from the terminal, but from the pipeline. There is no way you can get interactive user input from the default file descriptor, so you need to read it from somewhere else. /dev/tty is usually a good choice for reading from the terminal.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|