generic sftp script creation

I am trying to work out if it is possible to create a generic scrip which will allow sftp to be run for connecting to a host machine based on a parameter and to retrieve files based on a batch file. The batch file bit I am fine with, I can make that work. The are I'm not so sure about is how to parameterise the host machine and connection details.
I've trawled through previous threads on this, but they seem to relate to connecting to a single machine.
Does anyone have any suggestions? :wall:

I really never use sftp. I always just go with scp instead. Looking at the man page for sftp I see that batch files are designed for use with non-interactive authentication... so I assume you have that working. This script:

#! /usr/bin/ksh

CONTROL="Solaris1:/var/adm:messages
Linux1:/var/log:messages"


exec 4>&1
for line in $CONTROL ; do
        echo $line | IFS=: read HOST DIR FILE
        sftp $HOST  >&4 2>&4 |&
        print -p cd $DIR
        print -p get $FILE ${HOST}.${FILE}
        print -p bye
        wait
done
exit 0

does not use batch files but also depends on non-interactive authentication. I tested it and it worked. (Well, I did have have permission to get /var/log/messages on the Linux system... but other than that it worked.)

I still say that a simple scp would have been better.