Help with bash script

Dave Martini martini1 at llnl.gov
Fri Mar 13 21:22:20 UTC 2009


I am writing a bash script to run the nisclient command on a word list with
a for in loop. I'm using a  here document to accept user
input in this case I want it to be the letter y so that the script 
continues. When I run the script you'll see below it just asks
over and over if you want to continue y or n. I want the script
to enter y and continue.
If someone knows a better way and can provide the code that would be 
helpful as well.

Here is the script I have so far

bash-2.03# more change_nis_cred.sh
#This script script cycles through a word list and uses a for in loop.
set -x
#
for user in credlist.txt
do
# Start of Here document
#
nisclient -cl newpass $user <<- FINIS
echo "Changed $user account password"
         FINIS
done
bash-2.03#

This is what happens when I run the script

# ./change_nis_cred.sh
++ nisclient -cl newpass credlist.txt

You will be adding DES credentials in domain daveo.gov. for
credlist.txt

** nisclient will not overwrite any existing entries in the
** credential table.

Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n' to exit this script) 
Do you want to continue? (type 'y' to continue, 'n




More information about the redhat-list mailing list