You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by S D <sd...@gmail.com> on 2009/02/04 00:02:12 UTC

hadoop dfs -test question (with a bit o' Ruby)

I'm at my wit's end. I want to do a simple test for the existence of a file
on Hadoop. Here is the Ruby code I'm trying:

val = `hadoop dfs -test -e s3n://holeinthebucket/user/hadoop/file.txt`
puts "Val: #{val}"
if val == 1
  // do one thing
else
  // do another
end

I never get  a return value for the -test command. Is there something I'm
missing? How should the return value be retrieved?

Thanks,
SD

Re: hadoop dfs -test question (with a bit o' Ruby)

Posted by Norbert Burger <no...@gmail.com>.
I'm no Ruby programmer, but don't you need a call to system() instead of the
backtick operator here?  Appears that the backtick operator returns STDOUT
instead of the return value:

http://hans.fugal.net/blog/2007/11/03/backticks-2-0

Norbert

On Tue, Feb 3, 2009 at 6:03 PM, S D <sd...@gmail.com> wrote:

> Coincidentally I'm aware of the AWS::S3 package in Ruby but I'd prefer to
> avoid that...
>
> On Tue, Feb 3, 2009 at 5:02 PM, S D <sd...@gmail.com> wrote:
>
> > I'm at my wit's end. I want to do a simple test for the existence of a
> file
> > on Hadoop. Here is the Ruby code I'm trying:
> >
> > val = `hadoop dfs -test -e s3n://holeinthebucket/user/hadoop/file.txt`
> > puts "Val: #{val}"
> > if val == 1
> >   // do one thing
> > else
> >   // do another
> > end
> >
> > I never get  a return value for the -test command. Is there something I'm
> > missing? How should the return value be retrieved?
> >
> > Thanks,
> > SD
> >
>

Re: hadoop dfs -test question (with a bit o' Ruby)

Posted by S D <sd...@gmail.com>.
Coincidentally I'm aware of the AWS::S3 package in Ruby but I'd prefer to
avoid that...

On Tue, Feb 3, 2009 at 5:02 PM, S D <sd...@gmail.com> wrote:

> I'm at my wit's end. I want to do a simple test for the existence of a file
> on Hadoop. Here is the Ruby code I'm trying:
>
> val = `hadoop dfs -test -e s3n://holeinthebucket/user/hadoop/file.txt`
> puts "Val: #{val}"
> if val == 1
>   // do one thing
> else
>   // do another
> end
>
> I never get  a return value for the -test command. Is there something I'm
> missing? How should the return value be retrieved?
>
> Thanks,
> SD
>