# Difficulty accessing command line function return value (Hadoop FS shell)

**URL:** <https://www.ruby-forum.com/t/difficulty-accessing-command-line-function-return-value-hadoop-fs-shell/160468>\
**Category:** Ruby\
**Created:** [February 16, 2009, 7:12pm UTC](https://www.ruby-forum.com/t/difficulty-accessing-command-line-function-return-value-hadoop-fs-shell/160468 "2009-02-16T19:12:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![S\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@S\_D](https://www.ruby-forum.com/u/S_D)\
**Post date:** [February 16, 2009, 7:12pm UTC](https://www.ruby-forum.com/t/difficulty-accessing-command-line-function-return-value-hadoop-fs-shell/160468/1 "2009-02-16T19:12:50Z")

</div>

I’m attempting to use Hadoop FS shell (  
[http://hadoop.apache.org/core/docs/current/hdfs\_shell.html](http://hadoop.apache.org/core/docs/current/hdfs_shell.html)) within a  
ruby  
script. My challenge is that I’m unable to get the function return value  
of  
the commands I’m invoking. As an example Hadoop FS shell command, I try  
to  
run get ([http://hadoop.apache.org/core/docs/current/hdfs\_shell.html#get](http://hadoop.apache.org/core/docs/current/hdfs_shell.html#get))  
as  
follows

hadoop fs -get /user/hadoop/testFile.txt .

This should copy the file testFile.txt to my local directory. From the  
command line this generally works but I need to be able to verify that  
it is  
working in my ruby script. The command should return 0 on success and -1  
on  
error. Based on

[http://pasadenarb.com/2007/03/ruby-shell-commands.html](http://pasadenarb.com/2007/03/ruby-shell-commands.html)

I have assumed that I should use backticks to make the hadoop call and  
get  
the return value. Here is a dialogue within irb in which the command was  
not  
successful:

irb(main):001:0\> `hadoop dfs -get testFile.txt .`  
get: null  
=\> “”

and a dialogue within irb in which the command was successful

irb(main):010:0\> `hadoop dfs -get testFile.txt .`  
=\> “”

In both cases, neither a 0 nor a 1 appeared as a return value; indeed  
nothing was returned. I’m considering posting this as a bug on the  
Hadoop  
site but I want to make sure that I’m not doing something wrong from a  
Ruby  
point of view.

Your help is appreciated.

Thanks,  
John
