I am trying to run a hdfs dfs -ls
in a folder with pyspark
but I cant:
import subprocess
def run_cmd(args_list):
print('Running system command: {0}'.format(' '.join(args_list)))
proc = subprocess.Popen(args_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
s_output, s_err = proc.communicate()
s_return = proc.returncode
return s_return, s_output, s_err
hdfs_file_path = '/user/th/folder_4/files_4/'
cmd = ['hdfs', 'dfs', '-ls', hdfs_file_path]
ret, out, err = run_cmd(cmd)
print(ret, out,err)
It returns me the below. As you will see the output is '' but the folder has files:
(1, '', 'WARNING: log4j.properties is not found.')