code: func (c *Communicator) UploadScript(path string, input io.Reader) error {
  	reader := bufio.NewReader(input)
  	prefix, err := reader.Peek(2)
  	if err != nil {
  		return fmt.Errorf("Error reading script: %s", err)
  	}
  
  	var script bytes.Buffer
  	if string(prefix) != "#!" {
  		script.WriteString(DefaultShebang)
  	}
  
  	script.ReadFrom(reader)
  	if err := c.Upload(path, &script); err != nil {
  		return err
  	}
  
  	var stdout, stderr bytes.Buffer
  	cmd := &remote.Cmd{
  		Command: fmt.Sprintf("chmod 0777 %s", path),
  		Stdout:  &stdout,
  		Stderr:  &stderr,
  	}
  	if err := c.Start(cmd); err != nil {
  		return fmt.Errorf(
  			"Error chmodding script file to 0777 in remote "+
  				"machine: %s", err)
  	}
  
  	if err := cmd.Wait(); err != nil {
  		return fmt.Errorf(
  			"Error chmodding script file to 0777 in remote "+
  				"machine %v: %s %s", err, stdout.String(), stderr.String())
  	}
  
  	return nil
  }
docs: // UploadScript implementation of communicator.Communicator interface