Hello,
I am have an issues with one of my scripts. I get the following error when I get to the point in the script where I am making the change. The change does take however. the error is "change: xecho: execute permission denied"
Everything was working properly until I start cleaning up the code. (indent)
ans=y
while [ "$ans" = "y" ]
do
cat<<here0
${bold}Please enter the name of the user you want to change:${off}
here0
read name
clear
grep -in "$name" phonebook | sed -n -e 's/^/\
/' -e 's/:/\
/gp'
cat<<here1
${blink}${bold}Please enter the record that you want to change:${off}
here1
read number
record=`sed -n ${number}p phonebook`
name=`echo "$record"| cut -d: -f1`
address=`echo "$record"|cut -d: -f2`
city=`echo "$record"|cut -d: -f3`
state=`echo "$record"|cut -d: -f4`
zip=`echo "$record"|cut -d: -f5`
phone=`echo "$record"|cut -d: -f6`
echo "Do you want to change $name's name? (y/n) \c"
read ans
if [ "$ans" = "y" ]
then
echo "Please enter new name"
read newname
name=$newname
fi
xecho "Do you want to change $address? (y/n) \c"
read ans
if [ "$ans" = "y" ]
then
echo "Please enter new address"
read newaddress
address=$newaddress
fi
echo "Do you want to change $city? (y/n) \c"
read ans
if [ "$ans" = "y" ]
then
echo "Please enter new city"
read newcity
city=$newcity
fi
echo "Do you want to change $state? (y/n) \c"
read ans
if [ "$ans" = "y" ]
then
echo "Please enter new state"
read newstate
state=$newstate
fi
echo "Do you want to change $zip? (y/n) \c"
read ans
if [ "$ans" = "y" ]
then
echo "Please enter new zip"
read newzip
zip=$newzip
fi
echo "Do you want to change $phone? (y/n) \c"
read ans
if [ "$ans" = "y" ]
then
echo "Please enter new phone number"
read newphone
phone=$newphone
fi
sed "$number"d phonebook > phonebook.tmp
mv phonebook.tmp phonebook
echo "$name:$state:$city:$state:$zip:$phone" >> phonebook
echo "Would you like to change another record? /c"
read ans
done
---------- Post updated at 04:04 PM ---------- Previous update was at 03:14 PM ----------
Never mind I found the issue. It was a typo.
One other issue that I am having is when a user is not found in the file it hangs until the user presses return. How can I do some type of validation?
Thanks