# (no subject)

**URL:** <https://www.ruby-forum.com/t/no-subject/119175>\
**Category:** Ruby\
**Created:** [November 4, 2007, 11:27am UTC](https://www.ruby-forum.com/t/no-subject/119175 "2007-11-04T11:27:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![terry\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ccd318/32.png) [@terry\_p](https://www.ruby-forum.com/u/terry_p)\
**Post date:** [November 4, 2007, 11:27am UTC](https://www.ruby-forum.com/t/no-subject/119175/1 "2007-11-04T11:27:58Z")

</div>

This is my first thread on this mailing list, so bare with me.

I’ve this and it does download TARGET from the FTP server successfully  
– I  
also have accessed it via lukeftp, i.e. the ftp client that comes with  
my  
FreeBSD and OpenBSD systems here.

The problem seems to be that ‘pw = gets’ line and I don’t understand it.  
I  
have even tried closing the ftp connection before that and reopening it  
later  
but no success.

I’m clueless as to why I’m getting what looks to me like an  
Errno::ENOENT  
exception that references the ‘PATH’ we Net::FTP#chdir’d to four lines  
ago.  
When all it is doing is calling gets.

Test run:

C:\Documents and Settings\Owner\Desktop\>.\tg.rb “path with spaces”  
remote\_filename ftpsite username passwd

Password: C:/Documents and Settings/Owner/Desktop/tg.rb:32:in `gets’: No  
such fi  
le or directory - \< the path with spaces \> (Errno::ENOENT)  
from C:/Documents and Settings/Owner/Desktop/tg.rb:32

Test Code:

ftp = Net::FTP.new( HOST, USER, PASSWD, ACCT )  
ftp.chdir( PATH )  
ftp.gettextfile( TARGET )  
print( "Password: " )  
pw = gets  
print( “\n” )  
if pw  
# lock it  
else  
# un lock it  
end  
#ftp.puttextfile( TARGET )  
ftp.close  
puts( ‘Please restart the server for the changes to take effect’ )

end

Can any one give me a point in the right direction?

TerryP.

PS:

For any one who is interested in the shotty appearance of the test code.  
I  
_do_ build case prototypes as I go along. So I can test things out in  
small  
pieces before I begin putting together a ‘complete’ prototype and  
finally the  
finished program once I am done with testing 🙂

And oh yes I do plan on checking out what Ruby offers for Unit Testing  
in the  
future 😉

---

<div class="post-metadata">

**Author:** ![terry\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ccd318/32.png) [@terry\_p](https://www.ruby-forum.com/u/terry_p)\
**Post date:** [November 4, 2007, 11:30am UTC](https://www.ruby-forum.com/t/no-subject/119175/2 "2007-11-04T11:30:53Z")

</div>

Dang it… I forgot to set the subject line, sorry for the idiocy…

It is 0530 Sunday here and I’ve yet to sleep since Friday so please  
forgive  
the airhead move ^^

TerryP.

---

<div class="post-metadata">

**Author:** ![terry\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ccd318/32.png) [@terry\_p](https://www.ruby-forum.com/u/terry_p)\
**Post date:** [November 4, 2007, 11:44am UTC](https://www.ruby-forum.com/t/no-subject/119175/3 "2007-11-04T11:44:54Z")

</div>

Terry P. wrote:

> I’m clueless as to why I’m getting what looks to me like an Errno::ENOENT  
> exception that references the ‘PATH’ we Net::FTP#chdir’d to four lines ago.  
> When all it is doing is calling gets.

If you specify a command line parameter, Kernel#gets treats that as a  
file  
name and tries to read from that file instead of stdin. If you don’t  
want  
that, use STDIN.gets instead of Kernel#gets.

HTH,  
Sebastian

---

<div class="post-metadata">

**Author:** ![terry\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ccd318/32.png) [@terry\_p](https://www.ruby-forum.com/u/terry_p)\
**Post date:** [November 4, 2007, 12:35pm UTC](https://www.ruby-forum.com/t/no-subject/119175/4 "2007-11-04T12:35:47Z")

</div>

On 04.11.2007 11:43, removed\_email\_address@domain.invalid wrote:

> Terry P. wrote:
> 
> > I’m clueless as to why I’m getting what looks to me like an Errno::ENOENT  
> > exception that references the ‘PATH’ we Net::FTP#chdir’d to four lines ago.  
> > When all it is doing is calling gets.
> 
> If you specify a command line parameter, Kernel#gets treats that as a file  
> name and tries to read from that file instead of stdin. If you don’t want  
> that, use STDIN.gets instead of Kernel#gets.

I am sorry, but this is plain wrong.

[http://ruby-doc.org/core/classes/Kernel.html#M005995](http://ruby-doc.org/core/classes/Kernel.html#M005995)

robert

---

<div class="post-metadata">

**Author:** ![terry\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ccd318/32.png) [@terry\_p](https://www.ruby-forum.com/u/terry_p)\
**Post date:** [November 4, 2007, 1:09pm UTC](https://www.ruby-forum.com/t/no-subject/119175/5 "2007-11-04T13:09:46Z")

</div>

Robert K. wrote:

> On 04.11.2007 11:43, removed\_email\_address@domain.invalid wrote:
> 
> > If you specify a command line parameter, Kernel#gets treats that as a  
> > file name and tries to read from that file instead of stdin.
> 
> I am sorry, but this is plain wrong.
> 
> [module Kernel - RDoc Documentation](http://ruby-doc.org/core/classes/Kernel.html#M005995)

I’m sorry, maybe I’m a little slow, but isn’t “Returns (and assigns to  
$\_) the  
next line from the list of files in ARGV (or $\*), or from standard input  
if  
no files are present on the command line.” basically what I said?  
Or are you refering to the fact that my phrasing made it sound as if  
gets only  
cared about the first command line parameter?

---

<div class="post-metadata">

**Author:** ![terry\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ccd318/32.png) [@terry\_p](https://www.ruby-forum.com/u/terry_p)\
**Post date:** [November 4, 2007, 3:52pm UTC](https://www.ruby-forum.com/t/no-subject/119175/6 "2007-11-04T15:52:29Z")

</div>

On 04.11.2007 13:08, removed\_email\_address@domain.invalid wrote:

> no files are present on the command line." basically what I said?  
> Or are you refering to the fact that my phrasing made it sound as if gets only  
> cared about the first command line parameter?

I read your statement to mean that an argument to gets is treated as a  
file name. As is obvious now you were referring to the script’s  
arguments and not gets’s arguments. My apologies.

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![terry\_p](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ccd318/32.png) [@terry\_p](https://www.ruby-forum.com/u/terry_p)\
**Post date:** [November 4, 2007, 6:14pm UTC](https://www.ruby-forum.com/t/no-subject/119175/7 "2007-11-04T18:14:49Z")

</div>

Robert K. wrote:

> ICQ: 205544826

Works perfectly! I never realized there was a Kernel#gets as well, only  
knew  
about IO#gets. If I did know about it I would’ve just RTFM… Sorry =/

Thanks !

And thanks everyone for not flaming me for forgetting the subject  
line…

TerryP.
