Ruby libraries

Hi,

New to Ruby and I'm not having much luck finding the answer to this question at this time. Are there Ruby equivalents to the TWAPI extension library for TCL? I need to be able to "mount" a share from a script for Windows. I would also like to know if there is an FTP library that can be used in Ruby.

Currently, I'm using TCL, but I need to have threading support and to my pleasant surprise, Ruby supports threading natively. Plus, the language thus far, looks to be much more "fun" to work with than TCL.

Thanks in advance for any help provided.

···

---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled. I do not wish my account at HP to
become a spam haven.

Andrew-
     There is an ftp library in the ruby standard library. Here is a little script that recursively descends through a directory and uploads all the files to an ftp server:

#!/usr/local/bin/ruby
# This script uploads a folder of images via ftp

require 'find'
require 'net/ftp'

path = "/Volumes/Users/ez/logos/" # <= set this to the path of your folder of images

ftp = Net::FTP.new('ftp.example.com')
ftp.login("username", "password")
files = ftp.chdir('logos')

    Find.find(path) do |file|
        unless test(?d, file) #<= this tests to make sure its a file and not a directory before continuing.
          ftp.putbinaryfile("#{file}", "#{File.basename(file)}") #<= this assumes binary files.
          puts "Uploaded #{file}"
       end
   end

ftp.close

Hope that helps
-Ezra

···

On Jul 28, 2005, at 2:41 PM, Andrew Falanga wrote:

Hi,

New to Ruby and I'm not having much luck finding the answer to this question at this time. Are there Ruby equivalents to the TWAPI extension library for TCL? I need to be able to "mount" a share from a script for Windows. I would also like to know if there is an FTP library that can be used in Ruby.

Currently, I'm using TCL, but I need to have threading support and to my pleasant surprise, Ruby supports threading natively. Plus, the language thus far, looks to be much more "fun" to work with than TCL.

Thanks in advance for any help provided.

---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled. I do not wish my account at HP to
become a spam haven.

-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
509-577-7732
ezra@yakima-herald.com

Ezra Zygmuntowicz wrote:

Andrew-
    There is an ftp library in the ruby standard library. Here is a little script that recursively descends through a directory and uploads all the files to an ftp server:

#!/usr/local/bin/ruby
# This script uploads a folder of images via ftp

require 'find'
require 'net/ftp'

path = "/Volumes/Users/ez/logos/" # <= set this to the path of your folder of images

ftp = Net::FTP.new('ftp.example.com')
ftp.login("username", "password")
files = ftp.chdir('logos')

   Find.find(path) do |file|
       unless test(?d, file) #<= this tests to make sure its a file and not a directory before continuing.
         ftp.putbinaryfile("#{file}", "#{File.basename(file)}") #<= this assumes binary files.
         puts "Uploaded #{file}"
      end
  end

ftp.close

Hope that helps
-Ezra

Outstanding! I forgot to ask in the original post, however, that I also need a library for creating CRC's with a divisor of 32bits. Does something like this exist?

···

--

---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled. I do not wish my account at HP to
become a spam haven.

#: by Ezra Zygmuntowicz's words the mind was *winged* :#

Andrew-
     There is an ftp library in the ruby standard library. Here is a little script that recursively descends through a directory and uploads all the files to an ftp server:

#!/usr/local/bin/ruby
# This script uploads a folder of images via ftp

require 'find'
require 'net/ftp'

path = "/Volumes/Users/ez/logos/" # <= set this to the path of your folder of images

ftp = Net::FTP.new('ftp.example.com')
ftp.login("username", "password")
files = ftp.chdir('logos')

    Find.find(path) do |file|
        unless test(?d, file) #<= this tests to make sure its a file and not a directory before continuing.
          ftp.putbinaryfile("#{file}", "#{File.basename(file)}") #<= this assumes binary files.
          puts "Uploaded #{file}"
       end
   end

ftp.close

Hope that helps
-Ezra

Hi,

New to Ruby and I'm not having much luck finding the answer to this question at this time. Are there Ruby equivalents to the TWAPI extension library for TCL? I need to be able to "mount" a share from a script for Windows. I would also like to know if there is an FTP library that can be used in Ruby.

Currently, I'm using TCL, but I need to have threading support and to my pleasant surprise, Ruby supports threading natively. Plus, the language thus far, looks to be much more "fun" to work with than TCL.

Thanks in advance for any help provided.

---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled. I do not wish my account at HP to
become a spam haven.

-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
509-577-7732
ezra@yakima-herald.com

Wouldn't be correct to have the close() call in a finally block? (so to be assured that it always run)

:alex |.::the_mindstorm::.|

···

On Jul 28, 2005, at 2:41 PM, Andrew Falanga wrote:

Hi,

Andrew Falanga wrote:

Outstanding! I forgot to ask in the original post, however, that I also
need a library for creating CRC's with a divisor of 32bits. Does
something like this exist?

You can use Zlib.crc32 if you need CRC32-Reversed. And attached is my
port of CRC base functions in Classless.hasher at
http://www.classless.net/projects/hasher/ . Use this if you need CRC32
- not Reversed.

Regards,
// NaHi

crc.rb (3.09 KB)

Sure, I was just throwing up a quick example. If it's code you would be using a lot definitely put it in a begin ..rescue...ensure..end block.
-Ezra Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra@yakima-herald.com
509-577-7732

···

On Jul 28, 2005, at 7:18 PM, Alexandru Popescu wrote:

#: by Ezra Zygmuntowicz's words the mind was *winged* :#

Andrew-
     There is an ftp library in the ruby standard library. Here is a little script that recursively descends through a directory and uploads all the files to an ftp server:
#!/usr/local/bin/ruby
# This script uploads a folder of images via ftp
require 'find'
require 'net/ftp'
path = "/Volumes/Users/ez/logos/" # <= set this to the path of your folder of images
ftp = Net::FTP.new('ftp.example.com')
ftp.login("username", "password")
files = ftp.chdir('logos')
    Find.find(path) do |file|
        unless test(?d, file) #<= this tests to make sure its a file and not a directory before continuing.
          ftp.putbinaryfile("#{file}", "#{File.basename(file)}") #<= this assumes binary files.
          puts "Uploaded #{file}"
       end
   end
ftp.close
Hope that helps
-Ezra
On Jul 28, 2005, at 2:41 PM, Andrew Falanga wrote:

Hi,

New to Ruby and I'm not having much luck finding the answer to this question at this time. Are there Ruby equivalents to the TWAPI extension library for TCL? I need to be able to "mount" a share from a script for Windows. I would also like to know if there is an FTP library that can be used in Ruby.

Currently, I'm using TCL, but I need to have threading support and to my pleasant surprise, Ruby supports threading natively. Plus, the language thus far, looks to be much more "fun" to work with than TCL.

Thanks in advance for any help provided.

---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled. I do not wish my account at HP to
become a spam haven.

-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
509-577-7732
ezra@yakima-herald.com

Wouldn't be correct to have the close() call in a finally block? (so to be assured that it always run)

:alex |.::the_mindstorm::.|

      if (base & 1).nonzero?
        crc |= bitmask;
      else
        crc &= ~bitmask;
      end

No one must find extra semicolon at the end of line. :frowning:

  require 'zlib'
  p Zlib.crc32("12345")

  require 'pgp/util'
  p PGP::Util.crc24(msg)

FYI: You can find these implementations "RAA source code search" with
'crc'. cf. http://raa.ruby-lang.org/gonzui/search?q=crc

Regards,
// NaHi

···

2005/7/29, NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>: