you could also make the ftp section into each own function and call that function when required ...
Code:
hostname=box
user=user1
pass=passWd1
ftp_files(){
ftp -inv $hostname << !
user $user $pass
<commands..>
quit
!
}
if [ cond ]
then
ftp_files
else
<commands...>
fi