I'm using Airflow and i have some python scripts, one of it launch sh script (1 or many). For airflow even if this bash script return an error, it considers that the task is success.
I would like to return the bash error in my python script as airflow will notice.
import glob
import os
from os import path
import subprocess
odsPath = '/apps/data/02_OS/'
for odsFolder in os.listdir(odsPath):
if(odsFolder in fileNames):
newPath = odsPath+odsFolder
print('Script path: ', newPath)
for foldFiles in os.listdir(newPath):
if(foldFiles.endswith('sh')):
print('Sh script can be launch: ', foldFiles)
if(foldFiles.startswith('run') and foldFiles.endswith('.sh')):
os.system('sh ' + newPath+'/'+foldFiles)
print('Script: '+foldFiles+' executed')
In this case, there are bash errors, like this for example 'Number of parameters is incorrect'
Thanks for help :)