# Ensuring FTP calls complete

**URL:** <https://www.ruby-forum.com/t/ensuring-ftp-calls-complete/134604>\
**Category:** Ruby\
**Created:** [April 12, 2008, 7:32pm UTC](https://www.ruby-forum.com/t/ensuring-ftp-calls-complete/134604 "2008-04-12T19:32:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [April 12, 2008, 7:32pm UTC](https://www.ruby-forum.com/t/ensuring-ftp-calls-complete/134604/1 "2008-04-12T19:32:54Z")

</div>

I’m a mid level java guy trying out Ruby. I’m rewriting a java ftp app  
in Ruby to learn about this aspect of language. One thing I’ve been  
wondering is how Ruby handles problems encountered with ftp. For  
example, in Java (using the commons.net.ftp lib) I’m constantly  
checking to ensure my ftp calls actually work. When logging in, I check  
to make sure that the reply code indicates a successful login.  
Afterwards, I rely on the boolean return values provided by the methods  
in the library to know if I actually downloaded/uploaded a file, etc.

In the Ruby docs, the return\_code function is listed as “Obsolete.” In  
the examples I’ve studied, I haven’t seen the kind of checking I’m  
accustomed to writing. I realize that - examples being what they are -  
the focus is on brevity and functionality, and “boiler plate” code may  
be omitted.

What are the best practices in this case?

Thanks

---

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [April 13, 2008, 12:56pm UTC](https://www.ruby-forum.com/t/ensuring-ftp-calls-complete/134604/2 "2008-04-13T12:56:56Z")

</div>

Hi,

On Sun, Apr 13, 2008 at 3:32 AM, James Reynolds  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> In the Ruby docs, the return\_code function is listed as “Obsolete.”

It’s not only obsolete; quick squiz at the code reveals it does nothing:

```
def return_code
  $stderr.puts("warning: Net::FTP#return_code is obsolete and do

```

nothing")  
return “\n”  
end

The short answer is, net/ftp will (probably) throw an exception if  
something  
goes wrong. Try reading the code yourself, depending on what you do. I  
don’t  
have experience with it, but hopefully a guru here does.  
(on my system [Ubuntu], I can find net/ftp’s code at  
/usr/lib/ruby/1.8/net/ftp.rb)

Cheers,  
Arlen.
