Ftp

Whoops - incomplete message. As I was saying

···

-----Original Message-----
From: J.Hawkesworth
Sent: 01 August 2002 11:28
To: ‘ruby-talk@ruby-lang.org’
Subject: RE: ftp

I think what you are asking for is outside the remit of ftp.
As I understand it (and I may be wrong) ftp saves files according to the
umask (specified file permissions) defined in the ftp server’s
configuration. Its purpose is transfering files - something else has to
make the executable. I expect there is also a security justification
there somewhere too.

You can make dirs ftp.mkdir or delete dirs ftp.rmdir but there’s no
single command to do both. But presumably you can test for the presence
of a directory (using ftp.ls) and then delete the dir or whatever based
on the result.

While I’m typing I’d just like to say how much I like the ability to run
up irb, type in:
require ‘net/ftp’
ftp = Net::FTP::new(‘anftpserver’)
ftp.methods
and then see all of the methods that ftp supports:
[“return_code=”, “close”, “size”, “delete”, “list”, “acct”,
“gettextfile”, “retr
binary”, “voidcmd”, “connect”, “welcome”, “passive=”, “getdir”, “pwd”,
“nlst”, "
resume", “dir”, “ls”, “storbinary”, “sendcmd”, “debug_mode”, “resume=”,
“quit”,
“help”, “mdtm”, “rmdir”, “mtime”, “chdir”, “puttextfile”,
“getbinaryfile”, “retr
lines”, “return_code”, “debug_mode=”, “closed?”, “status”, “abort”,
“system”, “m
kdir”, “rename”, “putbinaryfile”, “storlines”, “login”, “lastresp”,
“passive”, "
new_cond", “try_mon_enter”, “mon_synchronize”, “mon_exit”, “mon_enter”,
“synchro
nize”, “==”, “public_methods”, “taint”, “equal?”, “===”, “inspect”,
“clone”, “ki
nd_of?”, “method”, “instance_eval”, “to_a”, “type”, “private_methods”,
“freeze”,
“id”, “extend”, “=~”, “eql?”, “singleton_methods”, “tainted?”, “is_a?”,
“method
s”, “dup”, “nil?”, “class”, “instance_of?”, “to_s”, “display”,
“instance_variabl
es”, “send”, “frozen?”, “id”, “send”, “untaint”, “respond_to?”,
“hash”,
“protected_methods”]

marvelous!

All the best,

Jon (ruby newbie)

-----Original Message-----
From: Andrew Davies [mailto:adavies@optushome.com.au]
Sent: 01 August 2002 01:40
To: ruby-talk ML
Subject: ftp

I uploaded from windows m.e. and I used:

ftp = Net::FTP.new(‘www.4gigs.com’, user, pass, )
files = ftp.chdir(‘public_html’)
ftp.puttextfile(‘it.rb’, ‘it.rb’)
ftp.close

Is there some command like maybe?
ftp.chmod( ‘it.rb’, 755 )

or ftp.make_or_remove_a_directory?

Andrew Davies


This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:



This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit


Any views or personal opinions expressed within this email may not be those of Talis Information Ltd.
The content of this email message and any files that may be attached are confidential, and for the usage of the intended recipient only. If you are not the intended recipient, then please return this message to the sender and delete it. Any use of this e-mail by an unauthorised recipient is prohibited.

Even better: replace two last lines with:

puts (Net::FTP.methods - Object.methods).sort,
"—", (Net::FTP.instance_methods - Object.instance_methods).sort

Slightly longer, but it gives you

  1. List of class methods not shared with Object
  2. List of instance methods not shared with Object

Actually, that in my .irbrc I have:

$ cat .irbrc
def help(obj)
if obj.class == Class
if obj != Object
c_list = (obj.methods - Object.methods).sort
i_list = (obj.instance_methods - Object.instance_methods).sort
else
c_list = obj.methods.sort
i_list = obj.instance_methods
end
a_list = obj.ancestors
else
c_list = (obj.class.methods - Object.methods).sort
i_list = (obj.class.instance_methods - Object.instance_methods).sort
a_list = obj.class.ancestors
end
puts “=”*50, “Class Methods”, “=”*50, c_list,
"="*50, “Instance Methods”, “=”*50, i_list,
"="*50, “Ancestors”, “=”*50, a_list
end

I really should clean that up, but it does what it is supposed to.

– Nikodemus

···

On Thu, 1 Aug 2002, J.Hawkesworth wrote:

While I’m typing I’d just like to say how much I like the ability to run
up irb, type in:

require 'net/ftp’
ftp = Net::FTP::new(‘anftpserver’)
ftp.methods

Very nice. I’ve appropriated it. Thanks!

···

----- Original Message -----
From: “Nikodemus Siivola” tsiivola@cc.hut.fi
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, August 01, 2002 9:25 PM
Subject: RE: ftp

$ cat .irbrc
def help(obj)
if obj.class == Class
if obj != Object
c_list = (obj.methods - Object.methods).sort
i_list = (obj.instance_methods - Object.instance_methods).sort
else
c_list = obj.methods.sort
i_list = obj.instance_methods
end
a_list = obj.ancestors
else
c_list = (obj.class.methods - Object.methods).sort
i_list = (obj.class.instance_methods - Object.instance_methods).sort
a_list = obj.class.ancestors
end
puts “=”*50, “Class Methods”, “=”*50, c_list,
"="*50, “Instance Methods”, “=”*50, i_list,
"="*50, “Ancestors”, “=”*50, a_list
end

I really should clean that up, but it does what it is supposed to.

– Nikodemus