Finally found a way to complete popen calls