[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

get files by its extension

Idealone Ideally

4/13/2009 4:20:00 AM

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
--
Posted via http://www.ruby-....

3 Answers

vimal

4/13/2009 5:29:00 AM

0

On Apr 13, 9:19 am, Idealone Ideally <sheka...@gmail.com> wrote:
> 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
> --
> Posted viahttp://www.ruby-....

Dir.glob('*.txt')

Regards,
Vimal Das

Robert Klemme

4/13/2009 11:50:00 AM

0

On 13.04.2009 07:29, vimal wrote:
> On Apr 13, 9:19 am, Idealone Ideally <sheka...@gmail.com> wrote:
>> 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

> Dir.glob('*.txt')

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

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

Especially method #nlst

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

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without end

vimal

4/14/2009 5:08:00 AM

0

On Apr 13, 4:50 pm, Robert Klemme <shortcut...@googlemail.com> wrote:
> On 13.04.2009 07:29, vimal wrote:
>
>
>
> > On Apr 13, 9:19 am, Idealone Ideally <sheka...@gmail.com> wrote:
> >> 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
> > Dir.glob('*.txt')
>
Sorry for the intervention guys, i didn't get your question properly.

Regards,
Vimal Das