Logic for file copy operation

Hi,
i need to copy contents from source to destination with a few conditions, Please helpme out.
Sample input file

$>cat testfile.txt
/a/b/c/d | /e/f/g/d 

(d can be either a file or directory)
my conditions are:
check if destination is valid and if its a file or directory
if its a directory(i.e source is a new file and does not already exist), copy the source(file) to destination
if its a file(there s a file with the same name as source file), take backup and copy the source(file) to destination
if not both, print error msg
Here is what i have tried:

 
#!/bin/ksh
src=`cat testfile.txt |awk -F\| '{print $1}' testfile.txt`
dst=`cat testfile.txt |awk -F\| '{print $2}' testfile.txt`
#collect all invalid, or check if source and destination are valid:
if [[ ! -f $src ]];then
      echo "Source does not exist"
      exit 0
fi
if [[ ! -d $dst && -f $dst ]];then
      echo "taking backup of existing $dst and copying new file from $src"
      mv $dst $dst.BAK
      cp $src $dst
elif [[ -d $dst && ! -f $dst ]];then
      echo "copying $src to $dst"
      cp $src $dst
else
      echo "Destination directory does not exist. Please check..."
      exit 0
fi

But this doesnt seem to be working. Please help

src=`cat testfile.txt |awk -F\| '{print $1}' testfile.txt`

is dubious (testfile.txt is provided both as stdin and as a parameter, should be provided once), use instead

 src=$(awk -F\| '{print $1}' testfile.txt)

sorry... that must have been a typo.... i have just

 
src=`awk -F\| '{print $1}' testfile.txt`
dst=`awk -F\| '{print $2}' testfile.txt`

Okay, so please elaborate on "this doesnt seem to be working".

Is there only one line in your file testfile.txt, well if that is the case then it will work.

But, if you have more than one line then you need to go for looping [preferrably while loop] and read one line at a time and execute the code you have on it.

Cheers,
Vishal

The OP gave a hint about that single line in testfile.txt with this cryptic sample:

$>cat testfile.txt
/a/b/c/d | /e/f/g/d

It tooks me some time to figure out the silly prompt ...