code: def script(state, host, filename, chdir=None):
      '''
      Upload and execute a local script on the remote host.
  
      + filename: local script filename to upload & execute
      + chdir: directory to cd into before executing the script
      '''
  
      temp_file = state.get_temp_filename(filename)
      yield files.put(state, host, filename, temp_file)
  
      yield chmod(temp_file, '+x')
  
      if chdir:
          yield 'cd {0} && {1}'.format(chdir, temp_file)
      else:
          yield temp_filf script(state, host, filename, chdir=None):
      '''
      Upload and execute a local script on the remote host.
  
      + filename: local script filename to upload & execute
      + chdir: directory to cd into before executing the script
      '''
  
      temp_file = state.get_temp_filename(filename)
      yield files.put(state, host, filename, temp_file)
  
      yield chmod(temp_file, '+x')
  
      if chdir:
          yield 'cd {0} && {1}'.format(chdir, temp_file)
      else:
          yield temp_file
docs: Upload and execute a local script on the remote host.
  
      + filename: local script filename to upload & execute
      + chdir: directory to cd into before executing the script