FAQ
Hi,

According to docs, I thought dfs -test -e URI would return 0 if file
exists,
but that does not appear to be the case.

- Fedora 9
- java
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)



test
Usage: hadoop dfs -test -[ezd] URI
Options:
-e check to see if the file exists. Return 0 if true.
-z check to see if the file is zero length. Return 0 if true
-d check return 1 if the path is directory else return 0.

This is what I get.

dfs -ls return code is 0 , this is ok.

[hadoop@cray64 hadoop-0.17.1]$ /home/hadoop/hadoop-0.17.1/bin/hadoop dfs
-ls /frank/unittest/tmpGeKbCF.txt
Found 1 items
/frank/unittest/tmpGeKbCF.txt <r 3> 13 2008-08-06 23:57
rw-r--r-- frank supergroup
[hadoop@cray64 hadoop-0.17.1]$ echo $?


Now run dfs -test -e on same file, note return code is 1

[hadoop@cray64 hadoop-0.17.1]$
[hadoop@cray64 hadoop-0.17.1]$ /home/hadoop/hadoop-0.17.1/bin/hadoop dfs
-test -e /frank/unittest/tmpGeKbCF.txt
[hadoop@cray64 hadoop-0.17.1]$ echo $?
1

This time try a file I know does not exist (I rrop the last char off the
end of the filename for test)
Note the return code is 0

[hadoop@cray64 hadoop-0.17.1]$
[hadoop@cray64 hadoop-0.17.1]$ /home/hadoop/hadoop-0.17.1/bin/hadoop dfs
-test -e /frank/unittest/tmpGeKbCF.tx
[hadoop@cray64 hadoop-0.17.1]$ echo $?

[hadoop@cray64 hadoop-0.17.1]$

Thanks / Frank

Search Discussions

  • Chris Douglas at Aug 7, 2008 at 5:24 pm
    Yes, this is backwards; it was fixed in HADOOP-3792 and committed to
    trunk (0.19). -C
    On Aug 6, 2008, at 10:44 PM, Frank Singleton wrote:

    Hi,

    According to docs, I thought dfs -test -e URI would return 0 if file
    exists,
    but that does not appear to be the case.

    - Fedora 9
    - java
    java version "1.6.0_07"
    Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
    Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)



    test
    Usage: hadoop dfs -test -[ezd] URI
    Options:
    -e check to see if the file exists. Return 0 if true.
    -z check to see if the file is zero length. Return 0 if true
    -d check return 1 if the path is directory else return 0.

    This is what I get.

    dfs -ls return code is 0 , this is ok.

    [hadoop@cray64 hadoop-0.17.1]$ /home/hadoop/hadoop-0.17.1/bin/hadoop
    dfs -ls /frank/unittest/tmpGeKbCF.txt
    Found 1 items
    /frank/unittest/tmpGeKbCF.txt <r 3> 13 2008-08-06 23:57
    rw-r--r-- frank supergroup
    [hadoop@cray64 hadoop-0.17.1]$ echo $?


    Now run dfs -test -e on same file, note return code is 1

    [hadoop@cray64 hadoop-0.17.1]$
    [hadoop@cray64 hadoop-0.17.1]$ /home/hadoop/hadoop-0.17.1/bin/hadoop
    dfs -test -e /frank/unittest/tmpGeKbCF.txt
    [hadoop@cray64 hadoop-0.17.1]$ echo $?
    1

    This time try a file I know does not exist (I rrop the last char off
    the end of the filename for test)
    Note the return code is 0

    [hadoop@cray64 hadoop-0.17.1]$
    [hadoop@cray64 hadoop-0.17.1]$ /home/hadoop/hadoop-0.17.1/bin/hadoop
    dfs -test -e /frank/unittest/tmpGeKbCF.tx
    [hadoop@cray64 hadoop-0.17.1]$ echo $?

    [hadoop@cray64 hadoop-0.17.1]$

    Thanks / Frank
  • Frank Singleton at Aug 7, 2008 at 6:34 pm

    Chris Douglas wrote:
    Yes, this is backwards; it was fixed in HADOOP-3792 and committed to
    trunk (0.19). -C
    On Aug 6, 2008, at 10:44 PM, Frank Singleton wrote:

    Hi,

    According to docs, I thought dfs -test -e URI would return 0 if file
    exists,
    but that does not appear to be the case.
    Hi Chris,

    Ok thanks !!

    /Frank

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommon-dev @
categorieshadoop
postedAug 7, '08 at 5:45a
activeAug 7, '08 at 6:34p
posts3
users2
websitehadoop.apache.org...
irc#hadoop

2 users in discussion

Frank Singleton: 2 posts Chris Douglas: 1 post

People

Translate

site design / logo © 2022 Grokbase