how to write scripts for automation