Doh! I figured it out - there was an abandoned ftp process from an earlier failed runthrough of the script. I killed the process, and my script runs fine now. Apparently it couldn't create another instance of this process with one still hanging out there, or something like that. Sigh...