I'm so confused about a python-file , which used for copying files from sever to hadoop.
the cmd is: hadoop fs -put /localhost/* /hadoop/*
the code is:
cmd = exc_path + ' ' + 'fs -put' + ' ' + src_path + item + ' ' + dst_path
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
code = process.wait()
logfile.info('type(code) is %s, code is %s\n', type(code), code)
For the past several days, it runs ok. But the day before yesterday it returned code!=0
Then yesterday, it ran ok, the code == 0
, and then today it fails and returned : type(code) is <type 'int'>, code is 255
The doc says the wait()
should return 0 or None, so why do I get a 255? And the cmd 'put' of hadoop should return 0 (when success) and -1 (when fail).
I have found some useful infomation: "Sadly when running your subprocess using shell=True, wait() will only wait for the sh subprocess to finish and not for the command cmd." from