read a line from a file and convert to a command in ksh

I am reading a file from a while loop (tested and it's reading it correctly, line by line), I'm just trying to convert the line into a command by adding "cp" in front of it and it's trying to execute the string.  The format of the file being read is:

./default/passwd /etc/default/passwd
inetd.conf /etc/inetd.conf
syslog.conf /etc/syslog.conf
shadow /etc/shadow
passwd /etc/passwd
group /etc/group
./default/login /etc/default/login
logadm.conf /etc/logadm.conf
profile /etc/profile
.ndel /etc/.ndl
.nodirect.sh /etc/.nodirect.sh

Here's the piece of code where I'm trying to add cp to the line, i.e., I want the first line to execute:
cp ./default/passwd /etc/default/passwd

while read line
ofile=print $line|awk '{print $2}'
do
         [ -f "$ofile" ] && mv $ofile $ofile.orig
         cp $line
         step="Copying standard $ofile" | tee -a ${SUCCESSLOG} ${FAILLOG}
done < ${MNT}/scripts/zone.etcfiles

Open in new window


Here's the errors I'm getting:
./Solaris_11.finish.final: line 336: ./default/passwd: cannot execute [Permission denied]
./Solaris_11.finish.final: line 336: inetd.conf: not found
./Solaris_11.finish.final: line 336: syslog.conf: not found
./Solaris_11.finish.final: line 336: shadow: not found
passwd: User unknown: /etc/passwd
./Solaris_11.finish.final: line 336: group: not found
./Solaris_11.finish.final: line 336: ./default/login: cannot execute [Permission denied]
./Solaris_11.finish.final: line 336: logadm.conf: not found
./Solaris_11.finish.final: line 336: profile: not found
./Solaris_11.finish.final: line 336: .ndl: not found
./Solaris_11.finish.final: line 336: .nodirect.sh: not found
LVL 1
David AldridgeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
while read ifile ofile
do
         [ -f "$ofile" ] && mv $ofile $ofile.orig
         cp $ifile $ofile
        step="Copying standard $ofile" | tee -a ${SUCCESSLOG} ${FAILLOG}
done < ${MNT}/scripts/zone.etcfiles

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David AldridgeAuthor Commented:
Once again, exactly what I need.  Thanks, ozo!

David
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.