Replace shell script with python one