# Ftp

**URL:** <https://www.ruby-forum.com/t/ftp/156073>\
**Category:** Ruby\
**Created:** [December 20, 2008, 1:59am UTC](https://www.ruby-forum.com/t/ftp/156073 "2008-12-20T01:59:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pratstercs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c4cdca/32.png) [@pratstercs](https://www.ruby-forum.com/u/pratstercs)\
**Post date:** [December 20, 2008, 1:59am UTC](https://www.ruby-forum.com/t/ftp/156073/1 "2008-12-20T01:59:41Z")

</div>

Hi,  
I’m a complete novice to Ruby, but I would like to write an FTP server  
to collect the files from my computer (internet connected) and copy them  
to my server nightly. My server is a Ubuntu Linux setup with FTP and  
blah. Please help me with this?

---

<div class="post-metadata">

**Author:** ![pratstercs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c4cdca/32.png) [@pratstercs](https://www.ruby-forum.com/u/pratstercs)\
**Post date:** [December 20, 2008, 3:04pm UTC](https://www.ruby-forum.com/t/ftp/156073/2 "2008-12-20T15:04:13Z")

</div>

Jeremy H. wrote:

> On 2008-12-20, Philip P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I’m a complete novice to Ruby, but I would like to write an FTP  
> > server to collect the files from my computer (internet connected)  
> > and copy them to my server nightly. My server is a Ubuntu Linux  
> > setup with FTP and blah. Please help me with this?
> 
> Do you need to do any programming at all? The NcFTP client at  
> [NcFTP Client](http://www.ncftp.com/ncftp/) can recursively download directories from  
> an FTP server to the local machine. I have used it to do that myself.  
> Is that not enough? Not that I want to put you off Ruby programming,  
> but it doesn’t seem necessary in this case.
> 
> Regards,
> 
> Jeremy H.

I would like to do this as a technical excercise first of all, plus I  
want it to do specific things at certain times like upload all files in  
a folder at 9PM every night, etc plus I want it to run from my Ubuntu  
server.

---

<div class="post-metadata">

**Author:** ![pratstercs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c4cdca/32.png) [@pratstercs](https://www.ruby-forum.com/u/pratstercs)\
**Post date:** [December 20, 2008, 3:35am UTC](https://www.ruby-forum.com/t/ftp/156073/3 "2008-12-20T03:35:35Z")

</div>

On 2008-12-20, Philip P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m a complete novice to Ruby, but I would like to write an FTP  
> server to collect the files from my computer (internet connected)  
> and copy them to my server nightly. My server is a Ubuntu Linux  
> setup with FTP and blah. Please help me with this?

Do you need to do any programming at all? The NcFTP client at  
[NcFTP Client](http://www.ncftp.com/ncftp/) can recursively download directories from  
an FTP server to the local machine. I have used it to do that myself.  
Is that not enough? Not that I want to put you off Ruby programming,  
but it doesn’t seem necessary in this case.

Regards,

Jeremy H.

---

<div class="post-metadata">

**Author:** ![pratstercs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c4cdca/32.png) [@pratstercs](https://www.ruby-forum.com/u/pratstercs)\
**Post date:** [December 22, 2008, 2:30am UTC](https://www.ruby-forum.com/t/ftp/156073/4 "2008-12-22T02:30:30Z")

</div>

On 2008-12-20, Philip P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I would like to do this as a technical excercise first of all, plus  
> I want it to do specific things at certain times like upload all  
> files in a folder at 9PM every night, etc plus I want it to run from  
> my Ubuntu server.

If you want it to run from your server then I think you’ll have to  
have some kind of mini-server on your local machine for your Ubuntu  
box to contact. That could be something standard such as ssh, which  
would let your server log in and scp files. Or perhaps FTP, and you  
could script it with Net::FTP. If you really want to do it all  
yourself you could write a server and client with DRb. That would be  
interesting! Of course you’d have to figure out the security  
implications of all this.

Regards,

Jeremy H.

---

<div class="post-metadata">

**Author:** ![pratstercs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c4cdca/32.png) [@pratstercs](https://www.ruby-forum.com/u/pratstercs)\
**Post date:** [December 22, 2008, 11:22am UTC](https://www.ruby-forum.com/t/ftp/156073/5 "2008-12-22T11:22:57Z")

</div>

> plus I want it to do specific things at certain times like upload all  
> files in a folder at 9PM every night

This is not so complicated.

First you should write a simple FTP “client” that connects to your  
host. This is quite trivial, i.e.

x = Net::FTP.new(‘[ftp.members.a1.net](http://ftp.members.a1.net)’)  
x.login(‘your\_name’,‘your\_password’)

Just look at the FTP class in ruby.

Once you can upload files, you can let this script run  
at fixed times. One way would be with cron, or with  
ruby daemons [http://rubyforge.org/projects/daemons/](http://rubyforge.org/projects/daemons/)
