hadoop,python:命令没有从脚本运行,也没有失败,但从命令行运行正常

时间:2012-07-20 13:57:45

标签: python hadoop hadoop-streaming

我有一个运行python命令的python程序

WARNING:root:executing - echo ~/Downloads/dw/hadoop_out/hadoop_out.2012-07-20 > /tmp/hadoop_load_file.tmp
WARNING:root:hadoop output file path written to /tmp/hadoop_load_file.tmp
WARNING:root:executing - /usr/local/hadoop/bin/hadoop dfs -cat ~/Downloads/dw/proposalLoader_out/part-00000 > ~/Downloads/dw/hadoop_out/hadoop_out.2012-07-20
WARNING:root:hadoop path exists, removing - /usr/local/hadoop/bin/hadoop dfs -test -d ~/Downloads/dw/proposalLoader_in
Deleted hdfs://master:54310/home/hduser/Downloads/dw/Loader_in
test: File does not exist: /home/hduser/Downloads/dw/Loader_out
WARNING:root:executing - /usr/local/hadoop/bin/hadoop dfs -mkdir ~/Downloads/dw/proposalLoader_in
WARNING:root:executing - /usr/local/hadoop/bin/hadoop dfs -copyFromLocal ~/Downloads/dw/load_input.txt ~/Downloads/dw/Loader_in  

但当我在HDFS看到什么时,我什么都没得到

$ hadoop dfs -ls ~/Downloads/dw/Loader_in
Found 1 items
-rw-r--r--   3 hduser supergroup          0 2012-07-20 06:49 /home/hduser/Downloads/dw/Loader_in/load_input.txt  

当我从shell运行相同的命令时,它会执行并获取HDFS

中的数据
$ /usr/local/hadoop/bin/hadoop dfs -copyFromLocal ~/Downloads/dw/load_input.txt ~/Downloads/dw/Loader_in

$ hadoop dfs -ls ~/Downloads/dw/Loader_in
Found 1 items
-rw-r--r--   3 hduser supergroup       2311 2012-07-20 06:50 /home/hduser/Downloads/dw/Loader_in

我不确定为什么我会看到这种行为,执行命令的代码如下

def execute(command):
    if not command:
        return (-1, 'command can not be empty or null')
    return subprocess.call(command, shell=True)

0 个答案:

没有答案