I hope this helps:
Look at some firewall scripts or run a search on google for ipaddress scripts. You should be able to come across some working examples.
I havent really ever used FTP from linux, but I'm sure that you can do everything from one command.
In bash-scripting you can easily redirect output to a file such as:
$IPADDRESS > /root/IPinfo.txt
At
www.linuxguruz.org they have some firewall scripts that get the ipaddress through scripting. Use some of that to get the ipaddress to a variable and then write it to a file. Then add a command to FTP that file to where ever you want.
Just run the ftp command with --help argument to get your switches and args to include in the command.