Adding comments to a node via drush or commandline
Expanding on Shawn Conn's answer, below is a Drush command that adds a comment to a Drupal 7 node.

Usage:

drush add-comment --uid=1 --subject='A comment' 'This is my awesome comment.'


Save the script below as add_comment.drush.inc, and place it in your $HOME/.drush directory.

&lt;?php

/**
 * Implements hook_drush_command().
 */
function add_comment_drush_command() {
  $items = array();

  $items['add-comment'] = array(
    'description' =&gt; "Add a comment to a node.",
    // Describe the arguments for this command.  Delete
    // this seciton if command takes no arguments.
    'arguments' =&gt; array(
      'comment' =&gt; 'The comment to add.',
    ),
    // List all options used for this command. Only options that
    // are listed here (or that are global Drush options) may
    // be specified on the commnadline; all others raise an error.
    'options' =&gt; array(
      'nid' =&gt; array(
        'description' =&gt; 'The node id to add the comment to.',
        'example-value' =&gt; '3',
      ),
      'subject' =&gt; 'The comment subject. Defaults to empty.',
      'uid' =&gt; 'The user id of the user to post the comment as. Defaults to anonymous.',
    ),
    // Give one or more example commandline usages for this command
    'examples' =&gt; array(
      'drush add-comment --nid=123 "This is my great comment."' =&gt; 'Do something.',
    ),
    'aliases' =&gt; array('addc'),
  );

  return $items;
}

/**
 * Implements hook_drush_help().
 *
 * @param
 *   A string with the help section (prepend with 'drush:')
 *
 * @return
 *   A string with the help text for your command.
 */
function add_comment_drush_help($section) {
  switch ($section) {
    case 'drush:add-comment':
      return dt("Brief help for Drush command add-comment.");
    // The 'title' meta item is used to name a group of
    // commands in `drush help`.  If a title is not defined,
    // the default is "All commands in ___", with the
    // specific name of the commandfile (e.g. add-comment).
    // Command files with less than four commands will
    // be placed in the "Other commands" section, _unless_
    // they define a title.  It is therefore preferable
    // to not define a title unless the file defines a lot
    // of commands.
    case 'meta:add-comment:title':
      return dt("add-comment commands");
    // The 'summary' meta item is displayed in `drush help --filter`,
    // and is used to give a general idea what the commands in this
    // command file do, and what they have in common.
    case 'meta:add-comment:summary':
      return dt("Summary of all commands in this command group.");
  }
}

/**
 * Implementation of drush_hook_COMMAND().
 *
 * Add a comment to a node.
 */
function drush_add_comment($comment) {
  $nid = drush_get_option('nid');
  $uid = drush_get_option('uid', 0);
  $subject = drush_get_option('subject', '');

  $comment = (object) array(
    'nid' =&gt; $nid,
    'cid' =&gt; 0,
    'pid' =&gt; 0,
    'uid' =&gt; $uid,
    'mail' =&gt; '',
    'is_anonymous' =&gt; ($uid == 0),
    'homepage' =&gt; '',
    'status' =&gt; COMMENT_PUBLISHED,
    'subject' =&gt; $subject,
    'language' =&gt; LANGUAGE_NONE,
    'comment_body' =&gt; array(
      LANGUAGE_NONE =&gt; array(
        0 =&gt; array (
          'value' =&gt; $comment,
          'format' =&gt; 'filtered_html'
        )
      )
    ),
  );

  comment_submit($comment);
  comment_save($comment);
}