Re: BASH Guru needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/26/03 14:21 -0500, Bill Gradwohl wrote:
> John:
 
> Thanks for the attempt, but the above doesn't work as expected. That was the first thing I tried early on.
> 
Bill,

This seems to work (credit to Advanced Bash-Scripting Guide, section
16.1, "Using exec"):

#!/bin/bash
cat >/tmp/junkfile <<-"CODE"
line 1
line 2
line 3
CODE

declare -a RULES
i=0
j=4
exec 6<&0               # Link file descriptor # 6 with stdin
exec </tmp/junkfile     # stdin replaced by /tmp/junfile
read RULES[0]
read RULES[1]
read RULES[2]
echo ${RULES[0]}
echo ${RULES[1]}
echo ${RULES[2]}
rm -r /tmp/junkfile
exec 0<&6 6<&-          # Restore stdin from fd #6
echo -n "Enter data:  " # Test restore
read b1
echo $b1

John


-- 
Shrike-list mailing list
Shrike-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/shrike-list

[Index of Archives]     [Fedora Users]     [Centos Users]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat Phoebe Beta]     [Yosemite Forum]     [Fedora Discussion]     [Gimp]     [Stuff]     [Yosemite News]

  Powered by Linux