Works out what type of command has been put into the method.

@param cmd The string of text from SServer.
@param f An instance of CommandFilter.
777688
public void run(String cmd, CommandFilter f) {

        CommandWords commandWord = null;

        if ( cmd.contains(" ") ) {
            try {
                commandWord = CommandWords.valueOf(cmd.substring(1, cmd.indexOf(" ")));
            } catch (IllegalArgumentException e) {
                commandWord = CommandWords.INVALID_COMMAND_WORD;
            }
        } else {
            commandWord = CommandWords.INVALID_COMMAND_WORD;
        }

        switch (commandWord) {
            case change_player_type:
                f.changePlayerTypeCommand(cmd.substring(20, cmd.length() - 1));
                break;
            case error:
                f.errorCommand(cmd.substring(7, cmd.length() - 1));
                break;
            case hear:
                f.hearCommand(cmd.substring(6, cmd.length() - 1));
                break;
            case init:
                f.initCommand(cmd.substring(6, cmd.length() - 1));
                break;
            case ok:
                f.okCommand(cmd.substring(4, cmd.length() - 1));
                break;
            case player_param:
                f.playerParamCommand(cmd.substring(14, cmd.length() - 1));
                break;
            case player_type:
                f.playerTypeCommand(cmd.substring(13, cmd.length() - 1));
                break;
            case see:
                f.seeCommand(cmd.substring(5, cmd.length() - 1));
                break;
            case see_global:
                f.seeCommand(cmd.substring(12, cmd.length() - 1));
                break;
            case sense_body:
                f.senseBodyCommand(cmd.substring(12, cmd.length() - 1));
                break;
            case server_param:
                f.serverParamCommand(cmd.substring(14, cmd.length() - 1));
                break;
            case warning :
                f.warningCommand(cmd.substring(9, cmd.length() - 1));
                break;
            case INVALID_COMMAND_WORD :
            default :
                throw new Error("Invalid command received: \"" + cmd + "\"");
        }
    }
818310
private ServerCommandID createServerCommand(String command) throws IOException {
        FileInputStream fis = null;
        BufferedReader reader = null;

        try {
            fis = new FileInputStream(commandFile);
            reader = new BufferedReader(new InputStreamReader(fis));
            String line = reader.readLine();
            if (line == null)
                line = "";

            return new ServerCommandID(line, command);
        } finally {
            if (!Utils.tryToClose(reader)) {
                Utils.tryToClose(fis);
            }
        }
    }
1072608
public void help(String command) {

        if ("*".equalsIgnoreCase(command)) {
            m_shell.help(null);
        } else if ("help".equalsIgnoreCase(command)) {
            help();
        } else {
            m_shell.help(command);
        }
    }
784158
public void command(String... args)
    {
        try
        {
            setArgs(args);
        }
        catch (CmdArgsException ex)
        {
            ex.printStackTrace();
            Logger logger = Logger.getLogger(CmdArgs.class.getName());
            logger.log(Level.SEVERE, Arrays.toString(args));
            logger.log(Level.SEVERE, ex.getMessage(), ex);
            logger.log(Level.SEVERE, ex.usage());
            System.exit(-1);
        }
    }
817033
public static void execCmd(String cmd){
		Process p = null;
		try {
			Runtime rt = Runtime.getRuntime();
			p = rt.exec(cmd);
			// 获取进程的标准输入流
			final InputStream is1 = p.getInputStream();
			// 获取进城的错误流
			final InputStream is2 = p.getErrorStream();
			// 启动两个线程，一个线程负责读标准输出流，另一个负责读标准错误流
			new Thread() {
				public void run() {
					BufferedReader br1 = new BufferedReader(
							new InputStreamReader(is1));
					try {
						String line1 = null;
						while ((line1 = br1.readLine()) != null) {
							if (line1 != null) {
							}
						}
					} catch (IOException e) {
						e.printStackTrace();
					} finally {
						try {
							is1.close();
						} catch (IOException e) {
							e.printStackTrace();
						}
					}
				}
			}.start();
				
			new Thread() {
				public void run() {
					BufferedReader br2 = new BufferedReader(
							new InputStreamReader(is2));
					try {
						String line2 = null;
						while ((line2 = br2.readLine()) != null) {
							if (line2 != null) {
							}
						}
					} catch (IOException e) {
						e.printStackTrace();
					} finally {
						try {
							is2.close();
						} catch (IOException e) {
							e.printStackTrace();
						}
					}
				}
			}.start();
			
			p.waitFor();
			p.destroy();
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				/*if( p.getErrorStream() != null ){
					p.getErrorStream().close();
				}
				if( p.getInputStream() != null ){
					p.getInputStream().close();
				}
				if( p.getOutputStream() != null ){
					p.getOutputStream().close();
				}*/
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
	}
1144645
protected final void printCommandLine(@Nonnull String[] cmd, @CheckForNull FilePath workDir) {
        StringBuilder buf = new StringBuilder();
        if (workDir != null) {
            buf.append('[');
            if(showFullPath)
                buf.append(workDir.getRemote());
            else
                buf.append(workDir.getRemote().replaceFirst("^.+[/\\\\]", ""));
            buf.append("] ");
        }
        buf.append('$');
        for (String c : cmd) {
            buf.append(' ');
            if(c.indexOf(' ')>=0) {
                if(c.indexOf('"')>=0)
                    buf.append('\'').append(c).append('\'');
                else
                    buf.append('"').append(c).append('"');
            } else
                buf.append(c);
        }
        listener.getLogger().println(buf.toString());
        listener.getLogger().flush();
    }
480116
function nameOfCommand(cmd) {
  if (!cmd) return "no command!";
  if (Array.isArray(cmd)) return nameOfCommand(cmd[0]);
  if (typeof cmd === "string") return cmd;
  if (cmd.name) return cmd.name;
  if (cmd.command) return cmd.command;
  return "unknown command, no name";
}
1227821
public void bindCommand(Control control, Command command) {
		commands.put(control, command);

		if (commandState.get(command) == null) {
			commandState.put(command, new CommandState());
		}
	}
493770
public int commandToDocType(String strCommand)
    {
        if (MessageLog.MESSAGE_SCREEN.equalsIgnoreCase(strCommand))
            return MessageLog.MESSAGE_SCREEN_MODE;
        if (MessageLog.SOURCE_SCREEN.equalsIgnoreCase(strCommand))
            return MessageLog.SOURCE_SCREEN_MODE;
        return super.commandToDocType(strCommand);
    }
985502
protected static String tryCommands (String[] cmds)
    {
        if (cmds == null) {
            return null;
        }

        String output;

        for (int ii = 0; ii < cmds.length; ii++) {
            output = runCommand(cmds[ii]);
            if (output != null) {
                return output;
            }
        }

        return null;
    }
189234
function execCommand(command, options, callback) {
		var args = [],
			extraArgs = (options.args || []).slice(0),
			preferGlobal = options.preferGlobal || false,
			srcSuccess = options.success,
			srcFailure = options.failure,
			success, failure;

		// remove processed options
		delete options.args;
		delete options.command;
		delete options.failure;
		delete options.preferGlobal;
		delete options.success;

		// must have output to satisfy success/failure conditions
		if (srcSuccess || srcFailure) {
			delete options.quiet;
		}

		// determine succes and failure types
		if (_.isRegExp(srcSuccess)) {
			success = function(data) { return srcSuccess.test(data); };
		} else if (_.isString(srcSuccess)) {
			success = function(data) { return data.toString().indexOf(srcSuccess) !== -1; };
		} else if (_.isFunction(srcSuccess)) {
			success = srcSuccess;
		} else if (!!success) {
			success = undefined;
			grunt.fail.warn('invalid type for success option, must be string, regexp, or function');
		}

		if (_.isRegExp(srcFailure)) {
			failure = function(data) { return srcFailure.test(data); };
		} else if (_.isString(srcFailure)) {
			failure = function(data) { return data.toString().indexOf(srcFailure) !== -1; };
		} else if (_.isFunction(srcFailure)) {
			failure = srcFailure;
		} else if (!!failure) {
			failure = undefined;
			grunt.fail.warn('invalid type for failure option, must be string, regexp, or function');
		}

		// create the list of command arguments
		Object.keys(options).forEach(function(key) {
			var value = options[key],
				isBool = _.isBoolean(value);
			if (!isBool || (isBool && !!value)) {
				args.push(camelCaseToDash(key));
			}
			if (!isBool) { args.push(value); }
		});
		args.unshift(command);

		// add non-option, non-flag arguments
		args = args.concat(extraArgs);

		// spawn command and output
		grunt.log.writeln('titanium ' + args.join(' '));
		var tiOpts = process.env.GRUNT_TITANIUM_TEST || success || failure ?
				{} : {stdio: 'inherit'},
			ti = spawn(getTitaniumPath(preferGlobal), args, tiOpts);

		// prepare functions for killing this process
		function killer(data) {
			grunt.log.write(data);
			if (ti.killed) {
				return;
			} else if (success && success(data)) {
				ti.kill();
				grunt.log.ok('titanium run successful');
			} else if (failure && failure(data)) {
				ti.kill();
				grunt.fail.warn('titanium run failed');
			}
		}

		// listen for success or failure conditions
		if (success || failure) {
			ti.stdout.on('data', killer);
			ti.stderr.on('data', killer);
		}

		// handle titanium's exit
		ti.on('close', function(code) {
			if (command !== 'build' || options.buildOnly) {
				if (code) {
					grunt.fail.fatal('titanium ' + command + ' failed.');
				} else {
					grunt.log.ok('titanium ' + command + ' complete.');
				}
			}
			return callback(ti.killed ? null : code);
		});

		// write output to a file for analysis in test specs
		if (process.env.GRUNT_TITANIUM_TEST) {
			var testFile = path.resolve('tmp', preferGlobal ? 'tmp_global.txt' : 'tmp.txt');
			grunt.file.mkdir(path.dirname(testFile));
			fs.writeFileSync(testFile, '');
			ti.stdout.on('data', function(data) {
				fs.appendFileSync(testFile, data);
			});
		}
	}
717755
def _filter_filecommands(self, filecmd_iter):
        
        if self.includes is None and self.excludes is None:
            return list(filecmd_iter())

        # Do the filtering, adjusting for the new_root
        result = []
        for fc in filecmd_iter():
            if (isinstance(fc, commands.FileModifyCommand) or
                isinstance(fc, commands.FileDeleteCommand)):
                if self._path_to_be_kept(fc.path):
                    fc.path = self._adjust_for_new_root(fc.path)
                else:
                    continue
            elif isinstance(fc, commands.FileDeleteAllCommand):
                pass
            elif isinstance(fc, commands.FileRenameCommand):
                fc = self._convert_rename(fc)
            elif isinstance(fc, commands.FileCopyCommand):
                fc = self._convert_copy(fc)
            else:
                self.warning("cannot handle FileCommands of class %s - ignoring",
                        fc.__class__)
                continue
            if fc is not None:
                result.append(fc)
        return result
1054831
function cmd (action, url, params, fn) {
      var c, f;

      c = {
        cmd: action + ' ' + me._selectedEnv.apiroot + url
      };

      c.params = ('object' === typeof(params)) ? params: {};
      c.params.eventKey = key();
      c.params.sid = sid();

      f = ('function' === typeof(fn)) ? fn: console.log;
      _commandQ['' + c.params.eventKey] = f;

      return JSON.stringify(c);
    }
855688
public void addLookCommand() {
        StringBuilder buf = new StringBuilder();
        buf.append("(look)");
        fifo.add(fifo.size(), buf.toString());
    }
1295701
public static void runShellCommand(String[] cmd,
                                     StringBuilder outputLines,
                                     StringBuilder errorLines)
    throws IOException {
    Process p = Runtime.getRuntime().exec(cmd);
    if (outputLines != null) {
      BufferedReader in =
        new BufferedReader(new InputStreamReader(p.getInputStream()));
      String line;
      while ((line = in.readLine()) != null) {
        outputLines.append(line);
      }
    }
    if (errorLines != null) {
      BufferedReader err =
        new BufferedReader(new InputStreamReader(p.getErrorStream()));
      String line;
      while ((line = err.readLine()) != null) {
        errorLines.append(line);
      }
    }
  }
759083
public boolean sendCommand(String command) {
        if (writer != null) {
            try {
                logger.info("Sending command " + command + " to remote host " + remoteHost);
                writer.write(command);
                writer.write('\r');
                writer.flush();
            } catch (IOException e) {
                logger.fatal("Error while sending command " + command + " to remote host " + remoteHost, e);
                return false;
            }
            return true;
        } else {
            return false;
        }
    }
506916
@Override
    protected void executeImpl(CommandLine cmd) {
        try {
            List<PropertyDefinition> defintions =
                new PropertyDefinitionListBuilder().addMillDb()
                                                   .build();
            PropertyVerifier verifier = new PropertyVerifier(defintions);
            verifier.verify(System.getProperties());
            ApplicationContext context =
                new AnnotationConfigApplicationContext("org.duracloud.mill.db",
                                                       "org.duracloud.mill.manifest.builder");
            log.info("context initialized");

            boolean dryRun = Boolean.valueOf(cmd.hasOption("d"));
            boolean clean = Boolean.valueOf(cmd.hasOption("C"));
            String host = cmd.getOptionValue("host");
            String port = cmd.getOptionValue("port", "443");
            String username = cmd.getOptionValue("u");
            String password = cmd.getOptionValue("p");
            List<String> spaceList = new LinkedList<>();
            if (cmd.hasOption("s")) {
                String spaces = cmd.getOptionValue("s", "");
                if (!StringUtils.isEmpty(spaces)) {
                    spaceList = Arrays.asList(spaces.split("[,]"));
                }
            }

            List<String> storeList = new LinkedList<>();

            if (cmd.hasOption("t")) {
                String stores = cmd.getOptionValue("t", "");
                if (!StringUtils.isEmpty(stores)) {
                    storeList = Arrays.asList(stores.split("[,]"));
                }
            }

            int threads = 0;
            if (cmd.hasOption("T")) {
                threads = Integer.parseInt(cmd.getOptionValue("T", "10"));
            }

            String account = host.split("[.]")[0];
            ContentStoreManager storeManager = new ContentStoreManagerImpl(host, port);
            storeManager.login(new Credential(username, password));
            Map<String, ContentStore> contentStoreMap = storeManager.getContentStores();
            List<ContentStore> contentStores = new LinkedList<>();
            for (String storeId : contentStoreMap.keySet()) {
                if (storeList.isEmpty() || storeList.contains(storeId)) {
                    ContentStore contentStore = contentStoreMap.get(storeId);
                    contentStores.add(contentStore);
                }
            }

            ManifestBuilder builder = (ManifestBuilder) context.getBean(ManifestBuilder.class);
            builder.init(account, contentStores, spaceList, clean, dryRun, threads);
            builder.execute();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        } finally {
            log.info("exiting...");
        }
    }