Better approach for executing shell commands