Start converting shell script to javascript