[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Redirecting stdin from within a script
From: |
Kyle |
Subject: |
Redirecting stdin from within a script |
Date: |
Tue, 16 Mar 2004 08:21:15 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 |
Seems like I used to be able to do this in a bash script (I'm running
2.05b):
5<a_file
while read line; do
echo $line
done <&5
But I'm getting the error: line 8: 5: Bad file descriptor
I need a script that will read from a file if a filename is specified or
otherwise just use stdin (for the remainder of the script).
I've tried a number of things, like:
if [ "$fname" != "" ]; then
0<$fname
fi
or
5<$fname
0<&5-
Is this a bug, or is there a way to get the file descriptor scope to
extend throughout the rest of the script?
Kyle
- Redirecting stdin from within a script,
Kyle <=