Get files by its extension

Hi Guys,
I want to download certain file types or certain files by its
name using ruby code.
example:
In Shell scripting, I can say cp .txt, which inturn copies all files
with extension “.txt”,
similarly i can say cp test
, all files with the string “test” are
copied.

I want to achieve similar tasks using ruby code, as i am novice using
ruby.
My purpose is that i am connecting to my Linux server through ftp and
trying to download files with certain extension.
Let me know if any more info is required from my end

cheers
Thanks in Advance

On Apr 13, 9:19 am, Idealone I. [email protected] wrote:

ruby.
My purpose is that i am connecting to my Linux server through ftp and
trying to download files with certain extension.
Let me know if any more info is required from my end

cheers
Thanks in Advance

Posted viahttp://www.ruby-forum.com/.

Dir.glob(‘*.txt’)

Regards,
Vimal Das

On Apr 13, 4:50 pm, Robert K. [email protected] wrote:

with extension “.txt”,
similarly i can say cp test* , all files with the string “test” are
copied.

I want to achieve similar tasks using ruby code, as i am novice using
ruby.
My purpose is that i am connecting to my Linux server through ftp and
trying to download files with certain extension.
Let me know if any more info is required from my end
Dir.glob(‘*.txt’)

Sorry for the intervention guys, i didn’t get your question properly.

Regards,
Vimal Das

On 13.04.2009 07:29, vimal wrote:

I want to achieve similar tasks using ruby code, as i am novice using
ruby.
My purpose is that i am connecting to my Linux server through ftp and
trying to download files with certain extension.
Let me know if any more info is required from my end

Dir.glob(‘*.txt’)

Does not work with FTP directories. Rather look at Net::FTP:

http://ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/index.html

Especially method #nlst

http://ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/classes/Net/FTP.html#M001128

Kind regards

robert