You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by Frank Singleton <b1...@gmail.com> on 2008/08/07 07:44:28 UTC
dfs -test -e question
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 $?
0
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 $?
0
[hadoop@cray64 hadoop-0.17.1]$
Thanks / Frank
Re: dfs -test -e question
Posted by Frank Singleton <b1...@gmail.com>.
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
Re: dfs -test -e question
Posted by Chris Douglas <ch...@yahoo-inc.com>.
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 $?
> 0
>
> 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 $?
> 0
> [hadoop@cray64 hadoop-0.17.1]$
>
> Thanks / Frank
>
>