Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 气流中的bash命令出现问题_Shell_Unix_Airflow_Airflow Operator - Fatal编程技术网

Shell 气流中的bash命令出现问题

Shell 气流中的bash命令出现问题,shell,unix,airflow,airflow-operator,Shell,Unix,Airflow,Airflow Operator,我的目标是运行一个本地python文件,在日志文件中附加一个日志,如果命令成功执行,则返回OK,如果命令失败,则返回NOK plus exit 1。 同样的代码是 RunDataException = BashOperator( task_id='run_data_exception', bash_command= '`python ~/BoulderDash/DataProcessingPipeline/data_exception_pipeline.py 2>&

我的目标是运行一个本地python文件,在日志文件中附加一个日志,如果命令成功执行,则返回OK,如果命令失败,则返回NOK plus exit 1。 同样的代码是

RunDataException = BashOperator(
    task_id='run_data_exception',    
    bash_command= '`python ~/BoulderDash/DataProcessingPipeline/data_exception_pipeline.py 2>&1 | tee -a $(pwd)/BoulderDash_output.log && echo "OK" || { echo "NOK" && exit 1; }`',
    dag=main_dag,
    email_on_failure = True,
    email = 'abc@xyz.com',
    on_failure_callback = throw_error
    )
即使我从登录中知道命令实际上失败了,我仍然收到OK消息。 有趣的是,如果我使用

enter`python ~/BoulderDash/DataProcessingPipeline/data_exception_pipeline.py 2>&1 $(pwd)/BoulderDash_output.log && echo "OK" || { echo "NOK" && exit 1; }`' 
在这里,我删除了| tee-a。然后,它打印出预期的NOK,但随后我将其写入日志的目标被击败。请帮我做这个

 bash_command= '`python ~/BoulderDash/DataProcessingPipeline/data_exception_pipeline.py 2> >(tee -a $(pwd)/BoulderDash_output.log) && echo "OK" || { echo "NOK" && exit 1; }`',
演示:


您可以使用
$?
:>:> BoulderDash_output.log 
:>eval 1/0  2> >(tee -a BoulderDash_output.log) && echo "OK" || { echo "NOK"; }
NOK
:>bash: 1/0: No such file or directory

:>cat BoulderDash_output.log 
bash: 1/0: No such file or directory
:>