# Problems ftp'ing

**URL:** <https://rubytalk.org/t/problems-ftping/28252>\
**Category:** ruby-talk\
**Created:** [16 June 2006 14:53 UTC](https://rubytalk.org/t/problems-ftping/28252 "2006-06-16T14:53:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guest16](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@Guest16](https://rubytalk.org/u/Guest16)\
**Post date:** [16 June 2006 14:53 UTC](https://rubytalk.org/t/problems-ftping/28252/1 "2006-06-16T14:53:23Z")

</div>

I keep getting errors with this simple ftp script. Real names and  
passwords have been changed to protect the innocent. I just need to send  
the input files to the ftp target without the extensions they have.

Thanks for any help.

1 require 'net/ftp'  
2 require 'FileUtils'  
3 Dir.chdir("E:/workflows/graphics/out/ps2k/100dpi")  
4 ArborTextfiles = Dir.glob("\*.100")  
5 ArborTextfiles.each do |file100|  
6 #file100.to\_s  
7 ftp = Net::FTP.open('[quack.bna.com](http://quack.bna.com)') do |ftp|  
8 ftp.login('xxxxx','xxxxx')  
9 ftp.chdir('/xxx/graphics/tiff\_100\_dpi')  
10 ftp.putbinaryfile(file100.sub(".100",""))  
11 end  
12 end

> **···**
>
> --------------------------------------------------------------------------------  
> These are the errors I get:
> 
> E:/live/RUBY/lib/ruby/1.8/net/ftp.rb:556:in `initialize': No such file  
> or direct  
> ory - test303 (Errno::ENOENT)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from E:/live/RUBY/lib/ruby/1.8/net/ftp.rb:556:in `putbinaryfile'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from e:/live/scripts/ruby/ftp/ArborTextimages2quack.rb:9  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from E:/live/RUBY/lib/ruby/1.8/net/ftp.rb:115:in `open'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from e:/live/scripts/ruby/ftp/ArborTextimages2quack.rb:6  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from e:/live/scripts/ruby/ftp/ArborTextimages2quack.rb:5
> 
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![CRIBBSJ](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@CRIBBSJ](https://rubytalk.org/u/CRIBBSJ)\
**Post date:** [16 June 2006 15:12 UTC](https://rubytalk.org/t/problems-ftping/28252/2 "2006-06-16T15:12:12Z")

</div>

Peter Bailey wrote:

> I keep getting errors with this simple ftp script. Real names and passwords have been changed to protect the innocent. I just need to send the input files to the ftp target without the extensions they have.
> 
> Thanks for any help.
> 
> 1 require 'net/ftp'  
> 2 require 'FileUtils'  
> 3 Dir.chdir("E:/workflows/graphics/out/ps2k/100dpi")  
> 4 ArborTextfiles = Dir.glob("\*.100")  
> 5 ArborTextfiles.each do |file100|  
> 6 #file100.to\_s  
> 7 ftp = Net::FTP.open('quack.bna.com') do |ftp|  
> 8 ftp.login('xxxxx','xxxxx')  
> 9 ftp.chdir('/xxx/graphics/tiff\_100\_dpi')  
> 10 ftp.putbinaryfile(file100.sub(".100",""))  
> &nbsp;&nbsp;

I think this should read:

ftp.putbinaryfile(file100, file100.sub(".100",""))

You could also do this:

ftp.putbinaryfile(file100, File.basename(file100, ".\*"))

Jamey

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.

---

<div class="post-metadata">

**Author:** ![Guest16](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@Guest16](https://rubytalk.org/u/Guest16)\
**Post date:** [16 June 2006 15:41 UTC](https://rubytalk.org/t/problems-ftping/28252/3 "2006-06-16T15:41:32Z")

</div>

Jamey Cribbs wrote:

> Peter Bailey wrote:
> 
> > 5 ArborTextfiles.each do |file100|  
> > 6 #file100.to\_s  
> > 7 ftp = Net::FTP.open('quack.bna.com') do |ftp|  
> > 8 ftp.login('xxxxx','xxxxx')  
> > 9 ftp.chdir('/xxx/graphics/tiff\_100\_dpi')  
> > 10 ftp.putbinaryfile(file100.sub(".100",""))  
> > &nbsp;&nbsp;
> 
> I think this should read:
> 
> ftp.putbinaryfile(file100, file100.sub(".100",""))
> 
> You could also do this:
> 
> ftp.putbinaryfile(file100, File.basename(file100, ".\*"))
> 
> Jamey
> 
> Confidentiality Notice: This email message, including any attachments,  
> is for the sole use of the intended recipient(s) and may contain  
> confidential and/or privileged information. If you are not the intended  
> recipient(s), you are hereby notified that any dissemination,  
> unauthorized review, use, disclosure or distribution of this email and  
> any materials contained in any attachments is prohibited. If you receive  
> this message in error, or are not the intended recipient(s), please  
> immediately notify the sender by email and destroy all copies of the  
> original message, including attachments.

Thanks a lot, Jamey. I used the latter. Now, what if I want to remove  
the file after I've ftp'd it? The variable "file100" wouldn't apply  
anymore, so, could I do a FileUtils.rm with the same File.basename  
string as the ftp?

Thanks.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Guest16](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@Guest16](https://rubytalk.org/u/Guest16)\
**Post date:** [16 June 2006 15:52 UTC](https://rubytalk.org/t/problems-ftping/28252/4 "2006-06-16T15:52:23Z")

</div>

Jamey Cribbs wrote:

> Peter Bailey wrote:
> 
> > 5 ArborTextfiles.each do |file100|  
> > 6 #file100.to\_s  
> > 7 ftp = Net::FTP.open('quack.bna.com') do |ftp|  
> > 8 ftp.login('xxxxx','xxxxx')  
> > 9 ftp.chdir('/xxx/graphics/tiff\_100\_dpi')  
> > 10 ftp.putbinaryfile(file100.sub(".100",""))  
> > &nbsp;&nbsp;
> 
> I think this should read:
> 
> ftp.putbinaryfile(file100, file100.sub(".100",""))
> 
> You could also do this:
> 
> ftp.putbinaryfile(file100, File.basename(file100, ".\*"))
> 
> Jamey
> 
> Confidentiality Notice: This email message, including any attachments,  
> is for the sole use of the intended recipient(s) and may contain  
> confidential and/or privileged information. If you are not the intended  
> recipient(s), you are hereby notified that any dissemination,  
> unauthorized review, use, disclosure or distribution of this email and  
> any materials contained in any attachments is prohibited. If you receive  
> this message in error, or are not the intended recipient(s), please  
> immediately notify the sender by email and destroy all copies of the  
> original message, including attachments.

Uh, I figured it out. Thanks, Jamey. I realized that "file100" was still  
perfectly valid for the original filenames, so, I didn't need anything  
fancy.

-Peter

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
