Implements run_script_cmd function to guess running environment from the file's extension