Script to transfer files

Hi,
I am new to scripting, I need to write a script to transfer .TXT files from Server A (ftp) to Server B. Once the files in server B i need to transfer it to server C (sftp). (not transfer of files directly from server A to Server C )

Thanks!
Regards
Sendhil

---------- Post updated at 09:24 PM ---------- Previous update was at 08:27 PM ----------

can anyone suggest me how write a condition to check for file in server B and go for sftp of server c

#!/usr/bin/sh
SERVERB="/path/of/SERVERB"
FILE=".TXT"
cd $SERVERB

## SERVER A
ftp -n hostname << EOF
user uid pwd
cd ftp/path
binary
prompt off
mget ${FILE}*
bye
EOF

###### got stuck here :wall: please help me out to write a condition which for the .TXT in server B and then only proceeds for next

## SERVER C 
sftp UsrID@hostname << End
cd sftp/path
binary 
prompt off
mput ${FILE}*
bye
End

Since sftp and scp are part of the ssh suite, can you use:

scp username@hostname:dirpath/\*.TXT .

??

I cant use ssh, so sftp script is good but the thing is need to connect both by a condition in such a way that if only the files from server A comes then the next psrt should come into picture.

got an idea of using if condition but failing to write as for the first time writing the script:(

check out rsync