How to execute php script using drush? I am new to Drush. How can I execute this script to remove comments of a specific user?

$uid = xx // the spam users id;
$query = db_query("SELECT cid FROM {comments} WHERE uid = %d", $uid);
while($cid = db_result($query)) {
  comment_delete($cid);
}


Also, that would be great if you could tell me how to complete the script so that it takes username instead of $uid.

Thanks
You can convert the script in a Drush shell script.


  A drush shell script is any Unix shell script file that has its "execute" bit set (i.e., via chmod +x myscript.drush) and that begins with a specific line:

    #!/usr/bin/env drush

  
  or 

    #!/full/path/to/drush



Drush scripts are better than Bash scripts for the following reasons:


They are written in PHP
Drush can bootstrap the site before running the script


The following is the example you can find on helloword.script.

#!/usr/bin/env drush

//
// This example demonstrates how to write a drush
// "shebang" script.  These scripts start with the
// line "#!/usr/bin/env drush" or "#!/full/path/to/drush".
//
// See `drush topic docs-scripts` for more information.
//
drush_print("Hello world!");
drush_print();
drush_print("The arguments to this command were:");

//
// If called with --everything, use drush_get_arguments
// to print the commandline arguments.  Note that this
// call will include 'php-script' (the drush command)
// and the path to this script.
//
if (drush_get_option('everything')) {
  drush_print("  " . implode("\n  ", drush_get_arguments()));
}
//
// If --everything is not included, then use
// drush_shift to pull off the arguments one at
// a time.  drush_shift only returns the user
// commandline arguments, and does not include
// the drush command or the path to this script.
//
else {
  while ($arg = drush_shift()) {
    drush_print('  ' . $arg);
  }
}

drush_print();


&nbsp;

You can made the script executable, so you can  execute it with &lt;script file&gt; &lt;parameters&gt; where &lt;script name&gt; is the script name, and &lt;parameters&gt; are the parameters passed to the script; if the script is not executable, you call it with drush &lt;script name&gt; &lt;parameters&gt;.